Flutter has abandonded its easy applicability, in particular for TextButtons.
I would like to have a transparent TextButton with a red text color. How do I implement that here and could you explain, why and how you use MaterialStateTextStyle
here?
TextButton.icon(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(Colors.transparent),
textStyle: MaterialStateTextStyle(color : Colors.red) // wrong
),
onPressed: () {},
icon: Icon(Icons.search),
label: Text('Search'),
);
3
Answers
This code can be used to make a transparent TextButton with red text color.
You can add color using parameter in Text and Icon like this: