import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:wow_english/common/extension/string_extension.dart'; class WEAppBar extends StatelessWidget implements PreferredSizeWidget { final String? titleText; final bool? centerTitle; final VoidCallback? onBack; final Color? backgroundColor; final PreferredSizeWidget? bottom; final Widget? leading; final double? leadingWidth; final List? actions; const WEAppBar({this.titleText, this.centerTitle = true, this.onBack, this.backgroundColor, this.bottom, this.leading, this.leadingWidth, this.actions, super.key}); @override Widget build(BuildContext context) { return AppBar( centerTitle: centerTitle, title: Text( titleText ?? '', style: TextStyle( fontSize: 25.sp, color: const Color(0xFF333333), fontWeight: FontWeight.w700, ), ), leadingWidth: leadingWidth, leading: leading ?? GestureDetector( onTap: () { if (onBack == null) { Navigator.pop(context); } else { onBack!(); } }, child: Container( alignment: Alignment.center, child: Image.asset( 'back_around'.assetPng, height: 40.h, width: 40.w, ), ), ), backgroundColor: backgroundColor ?? Colors.white, actions: actions ?? [], ); } @override // TODO: implement preferredSize Size get preferredSize => Size.fromHeight(kToolbarHeight + (bottom == null ? 0.0 : bottom!.preferredSize.height)); }