class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State {
var a = 1; //여기 만드는 변수는 state가 됩니다
Widget build(BuildContext context) {
return Scaffold(생략);
}
}
MaterialApp(
home: Scaffold(
floatingActionButtion: FloatingActionButton(
child : Text(a.toString()),
onPressed: (){
setState((){
a++
});
}
),
appBar: AppBar(),
body: 생략
),
)