Flutter Scaffold

参数详解

属性 说明
appBar 头部导航栏
body 主体
floatingActionButton 悬浮按钮
floatingActionButtonLocation 悬浮按钮位置
floatingActionButtonAnimator 悬浮按钮动画
persistentFooterButtons 显示在底部的一组按钮
drawer 侧拉抽屉菜单
endDrawer 侧拉抽屉菜单 与上面属性相反
bottomNavigationBar 显示在底部的导航栏
bottomSheet 要显示的持久底部工作表
backgroundColor 背景颜色
resizeToAvoidBottomPadding 已废弃
resizeToAvoidBottomInset 为true时:浮动小部件自动调整,以避免弹出键盘时被遮盖
primary 默认true
drawerDragStartBehavior 默认DragStartBehavior.start
extendBody 默认false
drawerScrimColor 抽屉打开时用来遮盖主要内容的涂布颜色

代码示例

Scaffold(
      appBar: AppBar(
        title: Text('我是appBar'),
      ),
      body: Align(alignment: Alignment.center,child: Text('我是body'),),
      floatingActionButton: FloatingActionButton(child: Text('点我'),
        onPressed: () {},
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      // floatingActionButtonAnimator: ,
      persistentFooterButtons: [
        IconButton(icon:Icon(Icons.add),onPressed: () {},),
        FlatButton(child: Text('哈哈'),
          onPressed: () {},),
        RaisedButton(
          child: Text('我是',style: TextStyle(color: Colors.white),),
          onPressed: () {},
        ),
        RaisedButton(
          child: Text('底部',style: TextStyle(color: Colors.white),),
          onPressed: () {},
        ),
        RaisedButton(
          child: Text('按钮',style: TextStyle(color: Colors.white),),
          onPressed: () {},
        )
      ],
      drawer: Drawer(child: Align(alignment: Alignment.center,child: Text('我是drawer'),),),
      endDrawer: Drawer(child: Align(alignment: Alignment.center,child: Text('我是endDrawer'),),),
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home), 
            title: Text('首页')
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.category), 
            title: Text('分类')
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.settings), 
            title: Text('设置')
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.account_circle), 
            title: Text('我的')
          ),
        ]
      ),
      bottomSheet: Text('我是bottomSheet'),
      backgroundColor: Colors.blue[100],
      // resizeToAvoidBottomPadding: ,
      resizeToAvoidBottomInset: true,
      primary: true,
      // drawerDragStartBehavior: DragStartBehavior.start,
      // extendBody: false,
      drawerScrimColor: Colors.red[100],
    );

效果图

Flutter Scaffold_第1张图片

完整代码

查看完整代码

你可能感兴趣的:(Flutter,基础)