I have an button, and when it gets pressed, an stateless Widget consisting of an Column with a few Text and an Image.Asset is shown. So now I have a few of these stateless Widgetswith different content. When I press the button, i want him now to show a ramdom one of these stateless Widgets, maybe an option for a specific order too.
How do I do that?
Button and comamnd for showing the Widget at the moment:
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
if (isShown == true) Zauberwuerfel(),
SizedBox(
width: 150,
height: 100,
),
Container(
padding: EdgeInsets.only(bottom: 60),
width: 230,
height: 130,
child: RaisedButton(
color: Colors.red,
child: Text('Skill', style: TextStyle(fontSize: 30)),
onPressed: () {
setState(() {
isShown = true;
One of those stateless Widgets:
class SkillJonglieren extends StatelessWidget {
Widget build(BuildContext context) {
return Column(children: <Widget>[
Text(
'Jonglieren',
style: TextStyle(fontSize: 35),
),
SizedBox(
width: 20,
height: 25,
),
Image.asset('images/jonglieren.jpg', scale: 5),
SizedBox(
width: 20,
height: 30,
),
Row(mainAxisAlignment: MainAxisAlignment.center, children: <Text>[
Text(
'Schwierigkeit:',
style: TextStyle(fontSize: 25),
),
Text(
' Einfach',
style: TextStyle(fontSize: 25, color: Colors.green),