getAppBar static method

dynamic getAppBar(
  1. BuildContext context, {
  2. String title = "",
  3. String appBarBackgroundColor = "#1b262c",
  4. Widget? leadingWidget,
  5. double? leadingWidth,
  6. Function? leadingAction,
  7. String? action1Txt,
  8. SystemUiOverlayStyle? systemOverlayStyle,
  9. Widget? titleView,
  10. String backIconColor = "#ffffff",
  11. double backIconSize = 20,
  12. PreferredSizeWidget? bottomWidget,
  13. bool isHideBottomLine = true,
  14. double appbarTitleFontSize = 17,
  15. String? titleColor,
  16. Widget? actionView,
  17. bool isLeading2WillPopScope = false,
  18. String bottomLineColr = "#dcdcdc",
  19. bool isHideMineLine = true,
})

Implementation

static getAppBar(BuildContext context,
    {String title = "",
      String appBarBackgroundColor = "#1b262c",
      Widget? leadingWidget,
      double? leadingWidth,
      Function? leadingAction,
      String? action1Txt,
      SystemUiOverlayStyle? systemOverlayStyle,
      Widget? titleView,
      String backIconColor = "#ffffff",
      double backIconSize = 20,
      PreferredSizeWidget? bottomWidget,
      bool isHideBottomLine = true,
      double appbarTitleFontSize = 17,
      String? titleColor,
      Widget? actionView,
      bool isLeading2WillPopScope=false,
      String bottomLineColr = "#dcdcdc",
      bool isHideMineLine=true,

    }) {
  return AppBar(
    backgroundColor: ColorsUtil.hex2Color(appBarBackgroundColor),
    systemOverlayStyle: systemOverlayStyle ?? SystemUiOverlayStyle.dark,
    //修改状态栏的字体颜色
    centerTitle: true,
    // 导航栏阴影
    elevation: isHideBottomLine ? 0 : 4,
    bottom: bottomWidget,
    leadingWidth: leadingWidth,
    shape:isHideMineLine?null: UnderlineInputBorder(
        borderSide: BorderSide(color: ColorsUtil.hex2Color(bottomLineColr), width: 0.5)
    ),
    //导航栏最左侧Widget,常见为抽屉菜单按钮或返回按钮。
    leading:isLeading2WillPopScope?null: leadingWidget ??
        GestureDetector(
          child: Icon(Icons.arrow_back_ios_new,
              size: backIconSize, color: ColorsUtil.hex2Color(backIconColor)),
          onTap: () {
            Navigator.pop(context);
          },
        ),
    title: titleView ??
        Text(
          title,
          style: TextStyle(
              color: titleColor == null
                  ? Colors.white
                  : ColorsUtil.hex2Color(titleColor),
              fontSize: appbarTitleFontSize,
              fontFamily: TextStyleUtils.getFontFamily(false),
              letterSpacing: 1.5),
        ),
    actions: [
      // AppBar中指定了actions按钮的约束条件,必须通过UnconstrainedBox来 “去除” 父元素的限制。
      Offstage(
        offstage: actionView == null,
        child: UnconstrainedBox(child: actionView),
      )
    ],
  );
}