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 @override
911 Widget build (BuildContext context) {
10- return MaterialApp (
12+ return const MaterialApp (
1113 title: 'Flutter Demo' ,
1214 home: MyHomePage (title: 'Flutter Demo Home Page' ),
1315 );
1416 }
1517}
1618
1719class MyHomePage extends StatefulWidget {
18- MyHomePage ({Key ? key, required this .title}) : super (key: key);
20+ const MyHomePage ({required this .title, Key ? key }) : super (key: key);
1921
2022 final String title;
2123
2224 @override
23- _MyHomePageState createState () => _MyHomePageState ();
25+ State < MyHomePage > createState () => _MyHomePageState ();
2426}
2527
2628class _MyHomePageState extends State <MyHomePage > {
@@ -40,7 +42,7 @@ class _MyHomePageState extends State<MyHomePage> {
4042 child: Column (
4143 mainAxisAlignment: MainAxisAlignment .center,
4244 children: < Widget > [
43- Text (
45+ const Text (
4446 'You have pushed the button this many times:' ,
4547 ),
4648 Text (
@@ -53,7 +55,7 @@ class _MyHomePageState extends State<MyHomePage> {
5355 floatingActionButton: FloatingActionButton (
5456 onPressed: _incrementCounter,
5557 tooltip: 'Increment' ,
56- child: Icon (Icons .add),
58+ child: const Icon (Icons .add),
5759 ),
5860 );
5961 }
0 commit comments