appbar.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. /// 页顶导航条
  4. class VAppBar extends AppBar {
  5. /// 标题文字
  6. final String? titleText;
  7. /// 标题组件
  8. final Widget? titleWidget;
  9. /// 右侧组件组
  10. @override
  11. final List<Widget>? actions;
  12. final BuildContext? context;
  13. final VoidCallback? iconBack;
  14. VAppBar({
  15. super.key,
  16. this.titleText,
  17. this.titleWidget,
  18. this.actions,
  19. this.context,
  20. this.iconBack,
  21. }) : super(
  22. elevation: 0,
  23. scrolledUnderElevation: 0,
  24. toolbarHeight: 60,
  25. backgroundColor: Colors.white,
  26. foregroundColor: Colors.green,
  27. flexibleSpace: Builder(builder: (context) {
  28. return Container(
  29. decoration: BoxDecoration(
  30. gradient: LinearGradient(
  31. colors: [
  32. Theme.of(context).primaryColor.withOpacity(.6),
  33. Theme.of(context).primaryColor,
  34. ],
  35. begin: Alignment.topRight,
  36. end: Alignment.bottomLeft,
  37. ),
  38. ),
  39. );
  40. }),
  41. leadingWidth: 88,
  42. leading: InkWell(
  43. onTap: () {
  44. iconBack?.call();
  45. Get.back();
  46. },
  47. child: SizedBox(
  48. width: 88,
  49. height: 60,
  50. child: Icon(
  51. Icons.arrow_back_ios_new,
  52. size: 36,
  53. color: Colors.white,
  54. ),
  55. ),
  56. ),
  57. centerTitle: true,
  58. titleTextStyle: const TextStyle(fontSize: 24),
  59. title: titleWidget ?? Text(titleText!),
  60. actions: actions,
  61. actionsIconTheme: const IconThemeData(size: 68, color: Colors.white),
  62. );
  63. }