Skip to content

Instantly share code, notes, and snippets.

@FlutterZeroGit
Created August 13, 2022 23:40
Show Gist options
  • Save FlutterZeroGit/16a4e3bd3e1f48988c26c950589b55fe to your computer and use it in GitHub Desktop.
Save FlutterZeroGit/16a4e3bd3e1f48988c26c950589b55fe to your computer and use it in GitHub Desktop.
StatefulWidget
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