getScaffold method
Widget
getScaffold(
- BuildContext context,
- Widget? child, {
- Key? key,
- String title = '',
- Color textColor = Colors.black,
- double? textSize,
- int? textLines,
- FontWeight? textWeight,
- TextAlign textAlign = TextAlign.start,
- String? textFamily,
- double? textScaleFactor,
- Widget? backGroundWidget,
- Color backGroundColor = Colors.white,
- bool showBack = true,
- Widget? leftWidget,
- Color lefIconColor = Colors.white,
- dynamic leftWidgetOnTap()?,
- Widget? titleWidget,
- List<
Widget> ? rightWidgets, - Widget? floatingActionButton,
- Color appBarColor = Colors.blueAccent,
- bool showAppBar = true,
- bool centerTitle = true,
- bool resizeToAvoidBottomInset = true,
- bool automaticallyImplyLeading = true,
- Widget? filexibleSpace,
- PreferredSizeWidget? bottom,
- bool isBackGroundTransparent = false,
- Color? shadowColor,
- double? elevation,
- ShapeBorder? shapeBorder,
- double? flexibleWidth,
- double? flexibleHeight,
- bool isShowTitle = true,
- DragStartBehavior drawerDragStartBehavior = DragStartBehavior.start,
- Color? drawerScrimColor,
- double? drawerEdgeDragWidth,
- bool drawerEnableOpenDragGesture = true,
- bool endDrawerEnableOpenDragGesture = true,
- Widget? drawer,
- Widget? endDrawer,
- dynamic onDrawerChanged()?,
- dynamic onEndDrawerChanged()?,
- bool primary = true,
- bool extendBody = false,
- bool extendBodyBehindAppBar = false,
- Widget? bottomSheet,
- CustomFloatingActionButtonLocation? location,
inherited
Implementation
@protected
Widget getScaffold(
BuildContext context,
Widget? child, {
Key? key, // 标识key
String title = '', // 标题
Color textColor = Colors.black, // 标题颜色
double? textSize, // 标题字体大小
int? textLines, // 标题最大行数
FontWeight? textWeight, // 标题字体粗细
TextAlign textAlign = TextAlign.start, // 标题对齐方式
String? textFamily, // 标题字体
double? textScaleFactor, // 标题缩放比例
Widget? backGroundWidget, // 背景widget
Color backGroundColor = Colors.white, // 背景颜色
bool showBack = true, // 是否显示返回按钮
Widget? leftWidget, // 左边widget
Color lefIconColor = Colors.white, // 左边图标颜色
Function()? leftWidgetOnTap, // 左边widget点击事件
Widget? titleWidget, // 标题widget
List<Widget>? rightWidgets, // 右边widget
Widget? floatingActionButton, // 悬浮按钮
Color appBarColor = Colors.blueAccent, // 头部颜色
bool showAppBar = true, // 是否显示头部
bool centerTitle = true, // 标题是否居中
bool resizeToAvoidBottomInset = true, // 是否自动调整大小
bool automaticallyImplyLeading = true, // 是否自动实现返回按钮
Widget? filexibleSpace, // 可折叠的空间
PreferredSizeWidget? bottom, // 头部底部
bool isBackGroundTransparent = false, // 背景是否透明
Color? shadowColor, // 阴影颜色
double? elevation, // 阴影高度
ShapeBorder? shapeBorder, // 头部形状
// BoxFit fit = BoxFit.fitWidth, // 背景图片填充方式
double? flexibleWidth, // 可折叠的宽度
double? flexibleHeight, // 可折叠的高度
bool isShowTitle = true, // 是否显示标题
DragStartBehavior drawerDragStartBehavior =
DragStartBehavior.start, // 抽屉拖动行为
Color? drawerScrimColor, // 抽屉遮罩颜色
double? drawerEdgeDragWidth, // 抽屉边缘拖动宽度
bool drawerEnableOpenDragGesture = true, // 抽屉是否可以拖动
bool endDrawerEnableOpenDragGesture = true, // 右抽屉是否可以拖动
Widget? drawer, // 抽屉
Widget? endDrawer, // 右抽屉
Function(bool)? onDrawerChanged, // 抽屉状态改变回调
Function(bool)? onEndDrawerChanged, // 右抽屉状态改变回调
bool primary = true, // 是否是主页面
bool extendBody = false, // 是否延伸body
bool extendBodyBehindAppBar = false, // 是否延伸body到头部
Widget? bottomSheet, // 底部弹出
Widget? bottomNavigationBar, // 底部导航栏
CustomFloatingActionButtonLocation? location, // 悬浮按钮位置
}) {
final leading = showBack
? leftWidget == null
? IconButton(
onPressed: () {
leftWidgetOnTap ?? Navigator.of(context).pop();
},
icon: Icon(
CupertinoIcons.back,
color: lefIconColor,
))
: InkWell(
onTap: leftWidgetOnTap?.call(),
child: leftWidget,
)
: null;
return Stack(
children: [
Positioned.fill(
child: backGroundWidget ?? const SizedBox(),
),
Positioned.fill(
child: Scaffold(
key: key,
backgroundColor:
isBackGroundTransparent ? Colors.transparent : backGroundColor,
resizeToAvoidBottomInset: resizeToAvoidBottomInset, //输入框抵住键盘
appBar: showAppBar
? AppBar(
elevation: elevation,
excludeHeaderSemantics: isBackGroundTransparent,
automaticallyImplyLeading: automaticallyImplyLeading,
backgroundColor: isBackGroundTransparent
? Colors.transparent
: appBarColor,
flexibleSpace: filexibleSpace
// ??
// FlexibleSpaceBar(
// background: BaseWidgetImageHelper.asset(
// BaseWidgetImageHelper.BASE_HEAD_BG,
// width: widget.flexibleWidth,
// height: widget.flexibleHeight,
// fit: widget.fit),
// )
,
shape: shapeBorder,
title: isShowTitle
? Text(
title,
textScaleFactor: textScaleFactor,
style: TextStyle(
fontSize: textSize,
color: textColor,
fontWeight: textWeight,
fontFamily: textFamily,
),
textAlign: textAlign,
overflow: TextOverflow.ellipsis,
maxLines: textLines,
)
: titleWidget,
centerTitle: centerTitle,
leading: leading,
actions: rightWidgets ?? [],
bottom: bottom,
shadowColor: isBackGroundTransparent
? Colors.transparent
: shadowColor,
)
: null,
floatingActionButton: floatingActionButton,
floatingActionButtonLocation: location,
drawer: drawer,
endDrawer: endDrawer,
drawerDragStartBehavior: drawerDragStartBehavior,
primary: primary,
extendBody: extendBody,
extendBodyBehindAppBar: extendBodyBehindAppBar,
drawerEdgeDragWidth: drawerEdgeDragWidth,
drawerEnableOpenDragGesture: drawerEnableOpenDragGesture,
drawerScrimColor: drawerScrimColor,
endDrawerEnableOpenDragGesture: endDrawerEnableOpenDragGesture,
onDrawerChanged: onDrawerChanged,
onEndDrawerChanged: onEndDrawerChanged,
bottomSheet: bottomSheet,
bottomNavigationBar: bottomNavigationBar,
body: child,
),
),
],
);
}