londonappbrewery / xylophone-flutter

Starter code for the Xylophone project in the Complete Flutter Bootcamp
https://www.appbrewery.co
115 stars 893 forks source link

FlatButton() is deprecated #46

Open FarhaanK opened 2 years ago

FarhaanK commented 2 years ago

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?

lawrence-cruz commented 2 years ago

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

ChandraShekharRajput commented 1 year ago

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

umutonal commented 1 year ago

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)), ), ); }

sarmad-hzn commented 1 year ago

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