Why is the screen blank?

Demo address: github.com/XinleiChenJ…

import 'package:flutter/material.dart'; void main()=>MyApp(); //MyApp does not need to do dynamic processing, So component extends StatelessWidget class MyApp extends StatelessWidget{// This component is the main component of the entire application. {return MaterialApp(
      title: 'StatelessWidget and StatefulWidget Examples', theme: ThemeData(// Custom theme primarySwatch: colors.blue), home: MyHomePage(title:'Examples of stateless and stateful Components')); }} class MyHomePage extends StatefulWidget extends StatefulWidget{// Title final String title; MyHomePage({Key key,this.title}):super(key:key); Override State createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage>{ int _count=0; void_incrementCounter(){// call the State classsetThe State method changes the status value, incrementing the counter by 1setState(() {// counter variable increment by 1 _count++; }); } @override Widget build(BuildContext context) {returnScaffold(appBar: appBar (title: Text(Widget.title),), // Center layout Body: Center(// vertical layout child: Column (/ / spindle center alignment mainAxisAlignment: mainAxisAlignment. The center, the children: < widgets > [Text ('How many times did you click on the bottom right button?'),
              Text(
                '$_count'Style: theme.of (context).textTheme.Display1,)],),), floatingActionButton: FloatingActionButton(onPressed: _incrementCounter,// Press the + button to call the increator tooltip:'add', child: Icon(Icons.add), ), ); }}Copy the code

Bad reasons

void main()=>MyApp();
Copy the code

This line of code is wrong

The solution

void main()=>runApp(MyApp());
Copy the code

Missing a runApp function

conclusion

The main() function only calls runApp() to fill the screen with the root component of the given layout, and the project can run without calling runApp(), but nothing is displayed on the screen. Flutter is the mobile application framework of the Dart language. RunApp () is the entry to the Flutter framework. If runApp() is not called, it is a Dart console application.