getScaffold method

  1. @protected
Widget getScaffold(
  1. BuildContext context,
  2. Widget? child, {
  3. Key? key,
  4. String title = '',
  5. Color textColor = Colors.black,
  6. double? textSize,
  7. int? textLines,
  8. FontWeight? textWeight,
  9. TextAlign textAlign = TextAlign.start,
  10. String? textFamily,
  11. double? textScaleFactor,
  12. Widget? backGroundWidget,
  13. Color backGroundColor = Colors.white,
  14. bool showBack = true,
  15. Widget? leftWidget,
  16. Color lefIconColor = Colors.white,
  17. dynamic leftWidgetOnTap()?,
  18. Widget? titleWidget,
  19. List<Widget>? rightWidgets,
  20. Widget? floatingActionButton,
  21. Color appBarColor = Colors.blueAccent,
  22. bool showAppBar = true,
  23. bool centerTitle = true,
  24. bool resizeToAvoidBottomInset = true,
  25. bool automaticallyImplyLeading = true,
  26. Widget? filexibleSpace,
  27. PreferredSizeWidget? bottom,
  28. bool isBackGroundTransparent = false,
  29. Color? shadowColor,
  30. double? elevation,
  31. ShapeBorder? shapeBorder,
  32. double? flexibleWidth,
  33. double? flexibleHeight,
  34. bool isShowTitle = true,
  35. DragStartBehavior drawerDragStartBehavior = DragStartBehavior.start,
  36. Color? drawerScrimColor,
  37. double? drawerEdgeDragWidth,
  38. bool drawerEnableOpenDragGesture = true,
  39. bool endDrawerEnableOpenDragGesture = true,
  40. Widget? drawer,
  41. Widget? endDrawer,
  42. dynamic onDrawerChanged(
    1. bool
    )?,
  43. dynamic onEndDrawerChanged(
    1. bool
    )?,
  44. bool primary = true,
  45. bool extendBody = false,
  46. bool extendBodyBehindAppBar = false,
  47. Widget? bottomSheet,
  48. Widget? bottomNavigationBar,
  49. 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,
        ),
      ),
    ],
  );
}