Scaffold 是 Flutter 中用于构建 Material Design 页面的核心组件,提供了丰富的属性来定义页面的布局和行为。这些属性,可以轻松实现常见的页面结构,如顶部应用栏、底部导航栏、抽屉菜单等
Scaffold Scaffold({
// key 组件中唯一的一个键值,用于标识和区分组件
Key? key,
// 应用栏(AppBar),通常显示在页面顶部
PreferredSizeWidget? appBar,
// 页面的主体内容
Widget? body,
// 悬浮操作按钮(Floating Action Button),通常用于主要操作
Widget? floatingActionButton,
// 悬浮操作按钮的位置
FloatingActionButtonLocation? floatingActionButtonLocation,
// 悬浮操作按钮的动画效果
FloatingActionButtonAnimator? floatingActionButtonAnimator,
// 固定在底部的按钮列表
List<Widget>? persistentFooterButtons,
// 固定在底部的按钮的对齐方式
AlignmentDirectional persistentFooterAlignment = AlignmentDirectional.centerEnd,
// 左侧抽屉菜单
Widget? drawer,
// 左侧抽屉菜单状态变化的回调函数
void Function(bool)? onDrawerChanged,
// 右侧抽屉菜单
Widget? endDrawer,
// 右侧抽屉菜单状态变化的回调函数
void Function(bool)? onEndDrawerChanged,
// 底部导航栏
Widget? bottomNavigationBar,
// 底部工作表(Bottom Sheet)
Widget? bottomSheet,
// 页面的背景颜色
Color? backgroundColor,
// 是否调整页面内容以避免底部被遮挡(如键盘弹出时)
bool? resizeToAvoidBottomInset,
// 是否将此 Scaffold 作为主页面(影响状态栏样式等)
bool primary = true,
// 抽屉菜单拖拽手势的起始行为
DragStartBehavior drawerDragStartBehavior = DragStartBehavior.start,
// 是否将底部导航栏延伸到页面底部
bool extendBody = false,
// 是否将页面内容延伸到应用栏后面
bool extendBodyBehindAppBar = false,
// 抽屉菜单打开时的遮罩颜色
Color? drawerScrimColor,
// 抽屉菜单边缘拖拽的宽度
double? drawerEdgeDragWidth,
// 是否启用左侧抽屉菜单的拖拽手势
bool drawerEnableOpenDragGesture = true,
// 是否启用右侧抽屉菜单的拖拽手势
bool endDrawerEnableOpenDragGesture = true,
// 页面恢复的 ID,用于状态恢复
String? restorationId,
})