class MyHomePage extends StatefulWidget{ const MyHomePage({super.key}); @override State<MyHomePage> createState() => MyHomePageState(); } class MyHomePageState extends State<MyHomePage>{ String _name = "Sumi"; Widget build(BuildContext context){ return Scaffold( body: Center(child: ElevatedButton( child: Text(_name), onPressed: (){ setState(() { }); _name = _name == "Sumi"?"Roma":"Sumi"; }, ), ), ); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter