![](https://thana.in.th/wp-content/uploads/2021/06/Screen-Shot-2564-06-21-at-17.04.23-1024x938.png)
![](https://thana.in.th/wp-content/uploads/2021/06/Screen-Shot-2564-06-21-at-17.05.32-1024x864.png)
![](https://thana.in.th/wp-content/uploads/2021/06/Screen-Shot-2564-06-21-at-16.12.46-1024x564.png)
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() { // called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
![](https://thana.in.th/wp-content/uploads/2021/06/Screen-Shot-2564-06-21-at-16.13.13-1024x274.png)
![](https://thana.in.th/wp-content/uploads/2021/06/Screen-Shot-2564-06-21-at-16.13.37-1024x952.png)
(Visited 151 times, 1 visits today)