flutter-基础控件

资料

Flutter 控件之 Scaffold

Widget

Scaffold

Scaffold 有下面几个主要属性:

  • appBar:显示在界面顶部的一个 AppBar,也就是 Android 中的 ActionBar 、Toolbar
  • body:当前界面所显示的主要内容 Widget
  • floatingActionButton:纸墨设计中所定义的 FAB,界面的主要功能按钮
  • persistentFooterButtons:固定在下方显示的按钮,比如对话框下方的确定、取消按钮
  • drawer:侧边栏控件
  • backgroundColor: 内容的背景颜色,默认使用的是 ThemeData.scaffoldBackgroundColor 的值
  • bottomNavigationBar: 显示在页面底部的导航栏
  • resizeToAvoidBottomPadding:类似于 Android 中的 android:windowSoftInputMode=”adjustResize”,控制界面内容 body 是否重新布局来避免底部被覆盖了,比如当键盘显示的时候,重新布局避免被键盘盖住内容。默认值为 true。
class MyApp2 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Demo'),
        ),
        body: new Builder(builder: (BuildContext context) {
          return new Center(
            child: new Center(
              child: new RaisedButton(
                  child: new Text('SHOW A SNCKBAR'),
                  onPressed: () {
                    Scaffold.of(context).showSnackBar(
                        new SnackBar(content: new Text('Hello!')));
                  }),
            ),
          );
        }),
      ),
    );
  }
}

你可能感兴趣的:(Flutter,Dart,flutter)