getAppBar static method
dynamic
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,
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),
)
],
);
}