I have some Buttons
wrapped inside a Card
and I need to add more when I have to.
I tried with Wrap.children.add
but it doesn't work, no error displayed, nothing changes.
Do you know how I can solve this?
I'm new in Flutter and dart so maybe I'm doing something stupid, I know.
I created a global variable called _MyWrap
and my idea is to add Buttons
to it when a Button is pressed.
"_getrandomButton" creates a new Button with a text inside(language) and "addRaisedButton" uses that function to create and add buttons to "Wrap" when the button is pressed.
A button that creates other "Buttons" inside a Wrap, this is it.
Code :
Wrap _MyWrap = new Wrap (children: <Widget>[]);
Widget build(BuildContext context) {
.
.
.
child: new Stack(
children: <Widget>[
new ListView(
children: <Widget>[
_addLanguage(),
],
.
.
.
Widget _addLanguage(){
RaisedButton _getrandomButton(String language){
//creates a RaisedButton
}
Future addRaisedButton(String name_) async{
setState(() {
_MyWrap.children.add(_getrandomButton(name_));
});
}
.
.
.
child : RaisedButton(
onPressed: (){
addRaisedButton("English");
},