import 'package:flutter/material.dart'; // Example: the focused code for this app. // A StatefulWidget that cycles through a list of strings each time the // button is pressed. class Example extends StatefulWidget { const Example({super.key}); @override State createState() => _ExampleState(); } class _ExampleState extends State { int counter = 0; List strings = ['Flutter', 'is', 'cool', "and", "awesome!"]; String displayedString = "Hello World!"; void onPressOfButton() { setState(() { displayedString = strings[counter]; counter = counter < 4 ? counter + 1 : 0; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Stateful Widget"), backgroundColor: Colors.green, ), body: Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text(displayedString, style: TextStyle(fontSize: 40.0)), Padding(padding: EdgeInsets.all(10.0)), ElevatedButton( style: ElevatedButton.styleFrom(backgroundColor: Colors.red), onPressed: onPressOfButton, child: Text( "Press me", style: TextStyle(color: Colors.white), ), ) ], ), ), ), ); } }