@@ -6,21 +6,12 @@ void main() => runApp(const MyApp());
6
6
class MyApp extends StatelessWidget {
7
7
const MyApp ({Key ? key}) : super (key: key);
8
8
9
- // This widget is the root of your application.
10
9
@override
11
10
Widget build (BuildContext context) {
12
11
return MaterialApp (
13
12
debugShowCheckedModeBanner: false ,
14
13
title: 'Flutter Module' ,
15
14
theme: ThemeData (
16
- // This is the theme of your application.
17
- //
18
- // Try running your application with "flutter run". You'll see the
19
- // application has a blue toolbar. Then, without quitting the app, try
20
- // changing the primarySwatch below to Colors.green and then invoke
21
- // "hot reload" (press "r" in the console where you ran "flutter run",
22
- // or press Run > Flutter Hot Reload in a Flutter IDE). Notice that the
23
- // counter didn't reset back to zero; the application is not restarted.
24
15
primarySwatch: Colors .blue,
25
16
),
26
17
home: const MyHomePage (title: 'Flutter Module' ),
@@ -31,15 +22,6 @@ class MyApp extends StatelessWidget {
31
22
class MyHomePage extends StatefulWidget {
32
23
const MyHomePage ({Key ? key, required this .title}) : super (key: key);
33
24
34
- // This widget is the home page of your application. It is stateful, meaning
35
- // that it has a State object (defined below) that contains fields that affect
36
- // how it looks.
37
-
38
- // This class is the configuration for the state. It holds the values (in this
39
- // case the title) provided by the parent (in this case the App widget) and
40
- // used by the build method of the State. Fields in a Widget subclass are
41
- // always marked "final".
42
-
43
25
final String title;
44
26
45
27
@override
@@ -51,51 +33,22 @@ class _MyHomePageState extends State<MyHomePage> {
51
33
52
34
void _incrementCounter () {
53
35
setState (() {
54
- // This call to setState tells the Flutter framework that something has
55
- // changed in this State, which causes it to rerun the build method below
56
- // so that the display can reflect the updated values. If we changed
57
- // _counter without calling setState(), then the build method would not be
58
- // called again, and so nothing would appear to happen.
59
36
_counter++ ;
60
37
});
61
38
}
62
39
63
40
@override
64
41
Widget build (BuildContext context) {
65
- // This method is rerun every time setState is called, for instance as done
66
- // by the _incrementCounter method above.
67
- //
68
- // The Flutter framework has been optimized to make rerunning build methods
69
- // fast, so that you can just rebuild anything that needs updating rather
70
- // than having to individually change instances of widgets.
71
42
return Scaffold (
72
43
appBar: AppBar (
73
44
leading: IconButton (
74
45
icon: const Icon (Icons .arrow_back_ios),
75
46
onPressed: () => SystemNavigator .pop (animated: true ),
76
47
),
77
- // Here we take the value from the MyHomePage object that was created by
78
- // the App.build method, and use it to set our appbar title.
79
48
title: Text (widget.title),
80
49
),
81
50
body: Center (
82
- // Center is a layout widget. It takes a single child and positions it
83
- // in the middle of the parent.
84
51
child: Column (
85
- // Column is also a layout widget. It takes a list of children and
86
- // arranges them vertically. By default, it sizes itself to fit its
87
- // children horizontally, and tries to be as tall as its parent.
88
- //
89
- // Invoke "debug painting" (press "p" in the console, choose the
90
- // "Toggle Debug Paint" action from the Flutter Inspector in Android
91
- // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
92
- // to see the wireframe for each widget.
93
- //
94
- // Column has various properties to control how it sizes itself and
95
- // how it positions its children. Here we use mainAxisAlignment to
96
- // center the children vertically; the main axis here is the vertical
97
- // axis because Columns are vertical (the cross axis would be
98
- // horizontal).
99
52
mainAxisAlignment: MainAxisAlignment .center,
100
53
children: < Widget > [
101
54
const Text (
@@ -112,7 +65,7 @@ class _MyHomePageState extends State<MyHomePage> {
112
65
onPressed: _incrementCounter,
113
66
tooltip: 'Increment' ,
114
67
child: const Icon (Icons .add),
115
- ), // This trailing comma makes auto-formatting nicer for build methods.
68
+ ),
116
69
);
117
70
}
118
71
}
0 commit comments