app-starlock/star_lock/lib/tools/titleAppBar.dart
2023-07-10 17:50:31 +08:00

39 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class TitleAppBar extends AppBar {
@override
final Color backgroundColor;
final String barTitle;
final Color titleColor;
final Color iconColor;
final bool haveBack;
final bool haveOtherLeftWidget;
final Widget leftWidget;
List<Widget> actionsList;
TitleAppBar({Key key,this.barTitle,this.titleColor,this.iconColor,this.backgroundColor,this.actionsList, this.haveBack, this.haveOtherLeftWidget = false , this.leftWidget}) : super(key: key);
@override
_TitleAppBarState createState() => _TitleAppBarState();
}
class _TitleAppBarState extends State<TitleAppBar> {
@override
Widget build(BuildContext context) {
return AppBar(
elevation: 0,
leading:widget.haveOtherLeftWidget?widget.leftWidget:(widget.haveBack?IconButton(
icon: Icon(Icons.arrow_back_ios,color: widget.iconColor??Colors.white),
onPressed: () => Navigator.of(context).pop(),
):Container()),
backgroundColor: widget.backgroundColor??Colors.white,
title: Text(widget.barTitle??'', style: TextStyle(color: widget.titleColor??Colors.white,fontSize: 36.sp, fontWeight:FontWeight.w500)),
centerTitle: true,
actions: widget.actionsList??[]
);
}
}