You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

79 lines
2.1 KiB

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
final Function onTap;
final Widget action;
final Widget bottom;
final Widget titleChild;
final String title;
final double titleSize;
final Color titleColor;
final Color leadingColor;
final Color background;
final Size preferredSize;
final double toolbarHeight;
final bool leading;
MyAppBar({
Key key,
this.onTap,
this.action,
this.bottom,
this.titleChild,
this.title,
this.toolbarHeight,
this.background = const Color(0xFFF7F7F7),
this.leadingColor = Colors.black,
this.titleColor = Colors.black,
this.titleSize = 18,
this.leading = true,
}) : preferredSize = Size.fromHeight(toolbarHeight ?? kToolbarHeight),
super(key: key);
@override
Widget build(BuildContext context) {
return AppBar(
backgroundColor: background,
elevation: 0,
leading: leading ? GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: Container(
alignment: Alignment.centerRight,
margin: EdgeInsets.only(left: 10.w),
padding: EdgeInsets.all(6),
child: Icon(
Icons.arrow_back_ios,
color: leadingColor,
size: 24,
),
),
) : Container(),
titleSpacing: 2,
centerTitle: false,
leadingWidth: leading ? 56.w : 10.w,
title: ((title == null || title == "") && titleChild != null)
? titleChild
: Text(
title,
style: TextStyle(
color: titleColor,
fontWeight: FontWeight.bold,
fontSize: titleSize,
),
),
actions: [
if (action != null)
Container(
margin: EdgeInsets.only(right: 15),
child: GestureDetector(
onTap: onTap,
child: action,
),
)
],
bottom: bottom,
);
}
}