实现圆角窗口请转:Flutter使用window_manager实现无边框窗口和圆角用到的插件 window_manager 窗口管理插件 - 掘金
插件
bitsdojo_window |Flutter 软件包
在pubspec.yaml文件添加bitsdojo_window最新的插件
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
bitsdojo_window: ^0.1.6
使用bitsdojo_window
在main函数里添加以下代码
import 'package:flutter/material.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
void main() {
runApp(const MyApp());
doWhenWindowReady(() {
const initialSize = Size(600, 450);
appWindow.minSize = initialSize;
appWindow.size = initialSize;
appWindow.alignment = Alignment.center;
appWindow.show();
});
}
UI代码
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
static const borderColor = Colors.deepPurpleAccent;
static const borderWidth = 1.0;
late AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: WindowBorder(
color: borderColor,
width: borderWidth,
child: Column(
children: [
WindowTitleBarBox(
child: Row(
children: [
Expanded(child: MoveWindow()),
MinimizeWindowButton(),
MaximizeWindowButton(),
CloseWindowButton()
],
),
),
Expanded(
child: Center(
child: Text('Custom Window Example'),
)
)
],
),
),
),
);
}
}