11import 'package:flutter/material.dart' ;
2- import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride;
2+ import 'package:flutter/foundation.dart'
3+ show debugDefaultTargetPlatformOverride;
34
45void main () {
56 // Override is necessary to prevent Unknown platform' flutter startup error.
@@ -24,15 +25,6 @@ class MyApp extends StatelessWidget {
2425class MyHomePage extends StatefulWidget {
2526 MyHomePage ({Key key, this .title}) : super (key: key);
2627
27- // This widget is the home page of your application. It is stateful, meaning
28- // that it has a State object (defined below) that contains fields that affect
29- // how it looks.
30-
31- // This class is the configuration for the state. It holds the values (in this
32- // case the title) provided by the parent (in this case the App widget) and
33- // used by the build method of the State. Fields in a Widget subclass are
34- // always marked "final".
35-
3628 final String title;
3729
3830 @override
@@ -44,47 +36,18 @@ class _MyHomePageState extends State<MyHomePage> {
4436
4537 void _incrementCounter () {
4638 setState (() {
47- // This call to setState tells the Flutter framework that something has
48- // changed in this State, which causes it to rerun the build method below
49- // so that the display can reflect the updated values. If we changed
50- // _counter without calling setState(), then the build method would not be
51- // called again, and so nothing would appear to happen.
5239 _counter++ ;
5340 });
5441 }
5542
5643 @override
5744 Widget build (BuildContext context) {
58- // This method is rerun every time setState is called, for instance as done
59- // by the _incrementCounter method above.
60- //
61- // The Flutter framework has been optimized to make rerunning build methods
62- // fast, so that you can just rebuild anything that needs updating rather
63- // than having to individually change instances of widgets.
6445 return Scaffold (
6546 appBar: AppBar (
66- // Here we take the value from the MyHomePage object that was created by
67- // the App.build method, and use it to set our appbar title.
6847 title: Text (widget.title),
6948 ),
7049 body: Center (
71- // Center is a layout widget. It takes a single child and positions it
72- // in the middle of the parent.
7350 child: Column (
74- // Column is also layout widget. It takes a list of children and
75- // arranges them vertically. By default, it sizes itself to fit its
76- // children horizontally, and tries to be as tall as its parent.
77- //
78- // Invoke "debug painting" (press "p" in the console, choose the
79- // "Toggle Debug Paint" action from the Flutter Inspector in Android
80- // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
81- // to see the wireframe for each widget.
82- //
83- // Column has various properties to control how it sizes itself and
84- // how it positions its children. Here we use mainAxisAlignment to
85- // center the children vertically; the main axis here is the vertical
86- // axis because Columns are vertical (the cross axis would be
87- // horizontal).
8851 mainAxisAlignment: MainAxisAlignment .center,
8952 children: < Widget > [
9053 Text (
@@ -101,7 +64,7 @@ class _MyHomePageState extends State<MyHomePage> {
10164 onPressed: _incrementCounter,
10265 tooltip: 'Increment' ,
10366 child: Icon (Icons .add),
104- ), // This trailing comma makes auto-formatting nicer for build methods.
67+ ),
10568 );
10669 }
10770}
0 commit comments