1. Create a test application of Flutter
Directory lib / main.dart
Code:
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Welcome to Flutter', home: new Scaffold( appBar: new AppBar( title: new Text('Welcome to Flutter'), ), body: new Center( child: new Text('Hello World'), ), ), ); } }
Description:
-
This example creates a Material APP. Material is a standard web end and the movable end visual design language. Flutter provides a rich set of Material widgets.
-
using the main function (
=>
) symbol, which is the one-way function or method Dart shorthand. -
The application inherits StatelessWidget, which will make the application itself has become a widget. In Flutter, most things are widget, comprising alignment (Alignment), padding (padding) and layout (layout)
-
Scaffold is a widget Material library provided, which provides a default navigation bar, and the title attribute contains the body home screen widget tree. widget tree can be very complex.
-
The main widget is to provide a build () method to describe how to display themselves in accordance with other lower-level widget.
-
The body of the present example includes a widget tree widget in Center, Center widget further comprises a sub-Text widget. Center widget its child widget tree to the center of the screen it can be.