Flutter学习二:最简单的Material Flutter应用

import 'package:flutter/material.dart';

void main() {
  //顶层容器,相当于rootview
  runApp(new MaterialApp(
    //标题
    title: "Flutter Application",
    //主题
    theme: new ThemeData(primaryColor: Colors.white),
    //home内容区
    home: new MyScaffold(),
  ));
}

class MyScaffold extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Material(
      child: new Scaffold(
        appBar: new AppBar(
          title: new Text(
            "AppBar",
            style: Theme.of(context).primaryTextTheme.title,
          ),
        ),
        body: new Center(
          child: new Text("Center"),
        ),
      ),
    );
  }
}
StatelessWidget是widget的无状态的子类,适合写静态widget。

效果图为:

猜你喜欢

转载自blog.csdn.net/sinat_29256651/article/details/81291751