11import 'package:flutter/material.dart' ;
22
33void main () {
4- runApp (MyApp ());
4+ runApp (const MyApp ());
55}
66
77class MyApp extends StatelessWidget {
8+ const MyApp ({Key ? key}) : super (key: key);
9+
810 // This widget is the root of your application.
911 @override
1012 Widget build (BuildContext context) {
@@ -22,13 +24,13 @@ class MyApp extends StatelessWidget {
2224 // is not restarted.
2325 primarySwatch: Colors .blue,
2426 ),
25- home: MyHomePage (title: 'Flutter Demo Home Page' ),
27+ home: const MyHomePage (title: 'Flutter Demo Home Page' ),
2628 );
2729 }
2830}
2931
3032class MyHomePage extends StatefulWidget {
31- MyHomePage ({Key ? key, required this .title}) : super (key: key);
33+ const MyHomePage ({Key ? key, required this .title}) : super (key: key);
3234
3335 // This widget is the home page of your application. It is stateful, meaning
3436 // that it has a State object (defined below) that contains fields that affect
@@ -42,7 +44,7 @@ class MyHomePage extends StatefulWidget {
4244 final String title;
4345
4446 @override
45- _MyHomePageState createState () => _MyHomePageState ();
47+ State < MyHomePage > createState () => _MyHomePageState ();
4648}
4749
4850class _MyHomePageState extends State <MyHomePage > {
@@ -93,7 +95,7 @@ class _MyHomePageState extends State<MyHomePage> {
9395 // horizontal).
9496 mainAxisAlignment: MainAxisAlignment .center,
9597 children: < Widget > [
96- Text (
98+ const Text (
9799 'You have pushed the button this many times:' ,
98100 ),
99101 Text (
@@ -106,7 +108,7 @@ class _MyHomePageState extends State<MyHomePage> {
106108 floatingActionButton: FloatingActionButton (
107109 onPressed: _incrementCounter,
108110 tooltip: 'Increment' ,
109- child: Icon (Icons .add),
111+ child: const Icon (Icons .add),
110112 ), // This trailing comma makes auto-formatting nicer for build methods.
111113 );
112114 }
0 commit comments