we_app_bar.dart 1.26 KB
import 'package:flutter/material.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 List<Widget>? actions;
  const WEAppBar({
    this.titleText,
    this.centerTitle = true,
    this.onBack,
    this.backgroundColor,
    this.bottom,
    this.leading,
    this.actions,
    super.key});

  @override
  Widget build(BuildContext context) {
    return AppBar(
      centerTitle: centerTitle,
      title: Text(titleText??''),
      leading: leading??GestureDetector(
        onTap: () {
          Navigator.pop(context);
        },
        child: Container(
          alignment: Alignment.center,
          child: Image.asset(
            'back_around'.assetPng,
            height: 40,
            width: 40,
          ),
        ),
      ),
      backgroundColor: backgroundColor??Colors.white,
      actions: actions??[],
    );
  }

  @override
  // TODO: implement preferredSize
  Size get preferredSize => Size.fromHeight(
      kToolbarHeight + (bottom == null ? 0.0 : bottom!.preferredSize.height));
}