customAppBar method

PreferredSizeWidget customAppBar({
  1. String? title,
  2. Widget? titleWidget,
  3. String? subTitle,
  4. List<Widget>? suffixWidget,
  5. VoidCallback? onBackPressed,
  6. TextStyle? titleStyle,
  7. Color? backgroundColor = AppColors.white,
  8. bool centerTitle = false,
  9. bool hideLeading = false,
  10. dynamic bottom,
  11. Color? leadingIconColor,
  12. Widget? leadingWidget,
  13. 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),
  );
}