Flutter基础widgets教程-Scaffold篇

简介: Flutter基础widgets教程-Scaffold篇

1 Scaffold

Scaffold 翻译过来就是脚手架的意思,它实现了基本的 Material Design 可视化布局结构。此类提供了用于显示drawer、snackbar和底部sheet的API。简单的说,Scaffold就是一个提供 Material Design 设计中基本布局的 widget。

2 构造函数

Scaffold({
  Key key,
  this.appBar, 
  this.body,undefined  this.floatingActionButton, 
  this.floatingActionButtonLocation, 
  this.floatingActionButtonAnimator, 
  this.persistentFooterButtons, 
  this.drawer, 
  this.endDrawer, 
  this.bottomNavigationBar,
  this.bottomSheet, 
  this.backgroundColor,
  this.resizeToAvoidBottomPadding = true, 
  this.primary = true,
})

复制

3 常用属性

3.1 appBar:显示在界面顶部的一个 AppBar

appBar: AppBar(
    title: Text(
        "Flutter Demo"
    ),
),

复制

3.2 body:当前界面所显示的主要内容 Widget

body: Center(
    child: Text(
        'Hello Flutter'
    ),
),

复制

3.3 drawer:侧边栏控件

drawer: Drawer(
    child: Center(
        child: Text('Drawer'),
    ),
),

复制

3.4 bottomNavigationBar:底部导航栏

bottomNavigationBar: new BottomNavigationBar(
    currentIndex: 1,//默认选中的位置
    fixedColor: Colors.green,//选中的颜色
    items:<BottomNavigationBarItem>
        new BottomNavigationBarItem(
            icon:new Icon(
                Icons.airplay,
            ),
            title: new Text(
                '主页',
            ),
         ),
         ......
     ,
),

复制

3.5 floatingActionButton:定义浮动在 body 右下角的组件

floatingActionButton: FloatingActionButton(
    onPressed: (){},
    child: Text('点击'),
),
相关文章
Flutter基础widgets教程-OverflowBox篇
Flutter基础widgets教程-OverflowBox篇
309 0
Flutter基础widgets教程-OverflowBox篇
Flutter基础widgets教程-SizedBox篇
Flutter基础widgets教程-SizedBox篇
218 0
Flutter基础widgets教程-SizedBox篇
|
数据可视化 API
Flutter基础widgets教程-Scaffold篇
Flutter基础widgets教程-Scaffold篇
143 0
Flutter基础widgets教程-AppBar篇
Flutter基础widgets教程-AppBar篇
102 0
Flutter基础widgets教程-Drawer篇
Flutter基础widgets教程-Drawer篇
146 0
Flutter基础widgets教程-SnackBar篇
Flutter基础widgets教程-SnackBar篇
169 0
Flutter基础widgets教程-FloatingActionButton篇
Flutter基础widgets教程-FloatingActionButton篇
195 0
|
索引
Flutter基础widgets教程-BottomNavigationBar篇
Flutter基础widgets教程-BottomNavigationBar篇
231 0
Flutter基础widgets教程-Divider篇
Flutter基础widgets教程-Divider篇
219 0
|
iOS开发
Flutter基础widgets教程-CupertinoNavigationBar篇
Flutter基础widgets教程-CupertinoNavigationBar篇
232 0