首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Flutter基础widgets教程-Scaffold篇

1 Scaffold

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

2 构造函数

代码语言:javascript
复制
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

代码语言:javascript
复制
appBar: AppBar(
    title: Text(
        "Flutter Demo"
    ),
),

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

代码语言:javascript
复制
body: Center(
    child: Text(
        'Hello Flutter'
    ),
),

3.3 drawer:侧边栏控件

代码语言:javascript
复制
drawer: Drawer(
    child: Center(
        child: Text('Drawer'),
    ),
),

3.4 bottomNavigationBar:底部导航栏

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

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

代码语言:javascript
复制
floatingActionButton: FloatingActionButton(
    onPressed: (){},
    child: Text('点击'),
),

下一篇
举报
领券