Scaffold属性概要
页面的脚手架
Scaffold({
// 键
Key key,
// 顶部导航栏
this.appBar,
// 应用主体部分
this.body,
// 悬浮按钮
this.floatingActionButton,
// 悬浮按钮位置
this.floatingActionButtonLocation,
// 悬浮按钮动画
this.floatingActionButtonAnimator,
// 底部按钮(在bottomNavigationBar)
this.persistentFooterButtons,
// 左侧菜单栏
this.drawer,
// 右侧菜单栏
this.endDrawer,
// 底部导航栏
this.bottomNavigationBar,
// 底部抽屉(应该不是底部抽屉的意思)
this.bottomSheet,
// 背景颜色
this.backgroundColor,
// 调整Scaffold大小,避免部件被遮挡住(如软键盘弹出时),已弃用,使用resizeToAvoidBottomInset代替
this.resizeToAvoidBottomPadding,
// 如果为true,则body和scaffold的浮动窗口小部件应自行调整大小,以避免屏幕键盘的高度由环境MediaQuery的MediaQueryData.viewInsets bottom属性定义
this.resizeToAvoidBottomInset,
// 一般情况下为默认为true,与appBar高度及显示位置有关
this.primary = true,
// 抽屉拖动启动行为
this.drawerDragStartBehavior = DragStartBehavior.start,
// 拓展体,值为true时,
this.extendBody = false,
// 抽屉蒙层颜色:抽屉打开没覆盖到的地方蒙层的颜色
this.drawerScrimColor,
// 抽屉边缘拖拽宽度:离抽屉多远可以拖拽出抽屉
this.drawerEdgeDragWidth,
})
key的创建,key相当于当前Scaffold的引用 ```dart final _scaffoldKey = GlobalKey
();
@override Widget build(BuildContext context) { return Scaffold( key: _scaffoldKey, body: Container( alignment: Alignment.bottomCenter, child: TextField(), ), ); }
```
- resizeToAvoidBottomInset及resizeToAvoidBottomPadding(已废弃,不推荐使用,和前者作用相同)属性差异比对
resizeToAvoidBottomInset值为false resizeToAvoidBottomInset值为true
- extendBody属性差异比对
extendBody值为false extendBody值为true