sys_app_bar.dart 1007 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import 'dart:io';
  2. import 'package:flutter/material.dart';
  3. import 'package:window_manager/window_manager.dart';
  4. class SysAppBar extends StatelessWidget implements PreferredSizeWidget {
  5. final double? toolbarHeight;
  6. final Widget? title;
  7. final List<Widget>? actions;
  8. const SysAppBar({Key? key, this.toolbarHeight, this.title, this.actions}) : super(key: key);
  9. @override
  10. Widget build(BuildContext context) {
  11. List<Widget> acs = [];
  12. if (actions != null) {
  13. acs.addAll(actions!);
  14. }
  15. if (Platform.isWindows || Platform.isLinux) {
  16. acs.add(CloseButton(onPressed: () => windowManager.close()));
  17. }
  18. return GestureDetector(
  19. onPanStart: (_) => windowManager.startDragging(),
  20. child: AppBar(
  21. toolbarHeight: preferredSize.height,
  22. title: title,
  23. actions: acs,
  24. backgroundColor: Colors.transparent,
  25. elevation: 0,
  26. ),
  27. );
  28. }
  29. @override
  30. Size get preferredSize => Size.fromHeight(toolbarHeight ?? kToolbarHeight);
  31. }