appbar.dart 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. final List<Widget>? actions;
  11. VAppBar({
  12. super.key,
  13. this.titleText,
  14. this.titleWidget,
  15. this.actions,
  16. }) : super(
  17. toolbarHeight: 90,
  18. backgroundColor: Colors.blue,
  19. foregroundColor: Colors.green,
  20. flexibleSpace: Container(
  21. decoration: const BoxDecoration(
  22. gradient: LinearGradient(
  23. colors: [
  24. Color.fromRGBO(59, 188, 255, 1),
  25. Color.fromRGBO(44, 120, 229, 1),
  26. ],
  27. begin: Alignment.topCenter,
  28. end: Alignment.bottomCenter,
  29. ),
  30. ),
  31. ),
  32. leadingWidth: 100,
  33. leading: IconButton(
  34. icon: const Icon(
  35. Icons.arrow_back_rounded,
  36. size: 68,
  37. color: Colors.white,
  38. ),
  39. onPressed: () {
  40. Get.back();
  41. },
  42. ),
  43. centerTitle: true,
  44. titleTextStyle: const TextStyle(fontSize: 24),
  45. title: titleWidget ?? Text(titleText!),
  46. actions: actions,
  47. actionsIconTheme: const IconThemeData(size: 68, color: Colors.white),
  48. );
  49. }