How can I change the background color of a textbutton in flutter?

backgroundColor property is MaterialStateProperty<Color?> type. You can check in Flutter documentation. So you have to use MaterialStateProperty class to apply color. A quick example : TextButton( child: Text(‘test’), style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.red)), onPressed: () {}, ), 2022 Update Since version 3.0.1, we can use MaterialStatePropertyAll as const. So it’s a better approach, to use it : …

Read more

Flutter Stack size to sibling

I had the same issue and finally managed to solve it using this answer: Inside your Stack, you should wrap your background widget in a Positioned.fill. return new Stack( children: <Widget>[ new Positioned.fill( child: background, ), foreground, ], ); — Mary, https://stackoverflow.com/a/45745479 Applying that to your question results in the following: Stack( children: <Widget>[ ListTile( …

Read more