123456789101112131415161718192021222324252627282930313233343536373839 |
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:window_manager/window_manager.dart';
- class SysAppBar extends StatelessWidget implements PreferredSizeWidget {
- final double? toolbarHeight;
- final Widget? title;
- final List<Widget>? actions;
- const SysAppBar({Key? key, this.toolbarHeight, this.title, this.actions}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- List<Widget> acs = [];
- if (actions != null) {
- acs.addAll(actions!);
- }
- if (Platform.isWindows || Platform.isLinux) {
- acs.add(CloseButton(onPressed: () => windowManager.close()));
- }
- return GestureDetector(
- onPanStart: (_) => windowManager.startDragging(),
- child: AppBar(
- toolbarHeight: preferredSize.height,
- title: title,
- actions: acs,
- backgroundColor: Colors.transparent,
- elevation: 0,
- ),
- );
- }
- @override
- Size get preferredSize => Size.fromHeight(toolbarHeight ?? kToolbarHeight);
- }
|