commonAppBar.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:get/get.dart';
  4. import '../resource/assets.gen.dart';
  5. class CommonAppBar extends StatelessWidget implements PreferredSizeWidget {
  6. final String title;
  7. final VoidCallback? onBack;
  8. final Color Function() backgroundColor;
  9. const CommonAppBar({
  10. super.key,
  11. required this.title,
  12. required this.backgroundColor,
  13. this.onBack,
  14. });
  15. @override
  16. @override
  17. Widget build(BuildContext context) {
  18. return AppBar(
  19. scrolledUnderElevation: 0,
  20. backgroundColor: backgroundColor(),
  21. leadingWidth: 40.w,
  22. leading: Padding(
  23. padding: EdgeInsets.only(left: 16.w),
  24. child: GestureDetector(
  25. onTap: onBack ?? Get.back,
  26. child: Assets.images.iconMineBackArrow.image(
  27. width: 24.w,
  28. height: 24.h,
  29. ),
  30. ),
  31. ),
  32. centerTitle: true,
  33. title: Text(
  34. title,
  35. textAlign: TextAlign.center,
  36. style: TextStyle(
  37. color: Colors.black.withAlpha(204),
  38. fontSize: 17.sp,
  39. fontWeight: FontWeight.w500,
  40. height: 1.18.h,
  41. ),
  42. ),
  43. );
  44. }
  45. @override
  46. Size get preferredSize => Size.fromHeight(kToolbarHeight);
  47. }