londonappbrewery / xylophone-flutter

Starter code for the Xylophone project in the Complete Flutter Bootcamp

Home Page:https://www.appbrewery.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FlatButton() is deprecated

FarhaanK opened this issue · comments

hi,
the FlatButton widget is deprecated the alternatives are TextButton or ElevatedButton but neither seem to have a color property like FlatButton. am i right? which button should i use in this project and how do i define its color?

You can use TextButton as an alternative to FlatButton.

To add color, just add the following code below:
style: TextButton.styleFrom(backgroundColor: Colors.red)

Here's an example:
image

hi, the FlatButton widget is deprecated the alternatives are TextButton or ElevatedButton but neither seem to have a color property like FlatButton. am i right? which button should i use in this project and how do i define its color?

Icon Button

hi,
the FlatButton widget is deprecated the alternatives are TextButton or ElevatedButton but neither seem to have a color property like FlatButton. am i right? which button should i use in this project and how do i define its color?

you can use it

Expanded buildKey({Color color, int soundNumber}) {
return Expanded(
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateColor.resolveWith((states) => color)),
),
);
}

Expanded(
child: TextButton(
onPressed: () {
playSound(7);
},
child: Text(''),
style: TextButton.styleFrom(backgroundColor: Colors.purple),
),
)