Created
August 13, 2022 23:40
-
-
Save FlutterZeroGit/16a4e3bd3e1f48988c26c950589b55fe to your computer and use it in GitHub Desktop.
StatefulWidget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatefulWidget { | |
MyApp({Key? key}) : super(key: key); | |
@override | |
State<MyApp> createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
String text = 'Hello World'; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar(title: Text('FlutterZero')), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
Text(text, style: TextStyle(fontSize: 30)), | |
SizedBox(height: 20), | |
ElevatedButton( | |
onPressed: () => setState(() { | |
text = 'I am Flutter'; | |
print(text); | |
}), | |
child: Text('Click'), | |
) | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment