customAppBar method
PreferredSizeWidget
customAppBar({
- String? title,
- Widget? titleWidget,
- String? subTitle,
- List<
Widget> ? suffixWidget, - VoidCallback? onBackPressed,
- TextStyle? titleStyle,
- Color? backgroundColor = AppColors.white,
- bool centerTitle = false,
- bool hideLeading = false,
- dynamic bottom,
- Color? leadingIconColor,
- Widget? leadingWidget,
- double? titleLeftPadding,
Implementation
PreferredSizeWidget customAppBar({
String? title,
Widget? titleWidget,
String? subTitle,
List<Widget>? suffixWidget,
VoidCallback? onBackPressed,
TextStyle? titleStyle,
Color? backgroundColor = AppColors.white,
bool centerTitle = false,
bool hideLeading = false,
var bottom,
Color? leadingIconColor,
Widget? leadingWidget,
double? titleLeftPadding,
}) {
return AppBar(
iconTheme: IconThemeData(
color: leadingIconColor,
),
centerTitle: centerTitle,
automaticallyImplyLeading: !hideLeading,
backgroundColor: backgroundColor,
bottom: bottom,
elevation: 0,
surfaceTintColor: Colors.transparent,
titleSpacing: 0,
leading: hideLeading
? const SizedBox.shrink()
: leadingWidget ??
(onBackPressed != null
? (Platform.isAndroid)
? IconButton(
onPressed: onBackPressed,
icon: const Icon(Icons.arrow_back),
)
: IconButton(
onPressed: onBackPressed,
icon: const Icon(Icons.arrow_back_ios),
)
: null),
leadingWidth: hideLeading ? 0 : null,
title: Padding(
padding: EdgeInsets.only(
left: titleLeftPadding ?? 0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
titleWidget ??
Text(
title ?? "",
style: titleStyle ?? Styles.tsBlack3BMedium14(),
),
if (subTitle != null)
Padding(
padding: const EdgeInsets.only(top: 2.0),
child: Text(
subTitle,
style: Styles.tsBlack3BRegular12Opacity(
opacity: 0.6,
),
),
),
],
),
),
actions: suffixWidget,
actionsPadding: EdgeInsets.only(right: 16),
);
}