So I've tried remaking a project I had but with newer versions of plugins and flutter, which led to some problems of course haha, now I'm dealing with the last issue (I hope so) to which I cant find an answer.
part of it in main.dart :
Expanded buildKey(Color a, int num){
return Expanded(
child: FlatButton(
color: a,
onPressed: () {
playSound(num);
}),);}
part of pubspec.yaml
version: 1.0.0 1
environment:
sdk: ">=2.17.5 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.5
english_words: ^4.0.0
audioplayers: ^1.0.1
it requires implementing a child to the flatbutton even though in older versions this code worked just fine, I don't know what child widget to implement w/o making any drastic changes
I appreciate any help regarding this topic, if you need any extra information just tell me and ill provide it.
CodePudding user response:
FlatButton is deprecated , I recommended use TextButton like this:
TextButton(
style:
ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.red)),
onPressed: (){}, child: SizedBox(),
),
but you can use FlatButton with empty child like this:
FlatButton(
color: a,
onPressed: () {
playSound(num);
},
child: SizedBox()
)
CodePudding user response:
child
is Widget
. However, Flutter recommends using TextButton
rather than FlatButton
.
FlatButton(
onPressed: (){},
child: Text("Button"),
),
TextButton(
onPressed: (){},
child: Text("Button"),
),