Flutter窗口管理插件flutter_window的使用
Flutter窗口管理插件flutter_window的使用
flutter_window
一个可以拖拽缩放的窗口组件。
平台
Android | Windows | Linux | Web | MacOS | iOS |
---|---|---|---|---|---|
❌ | ❌ | ❌ | ✔️ | ❌ | ❌ |
时间有限,暂时只测试了Web平台。
安装
在pubspec.yaml
文件添加依赖:
dependencies:
flutter_window: ^latest_version
示例
以下是一个完整的示例代码:
import 'package:flutter/material.dart';
import 'package:flutter_window/property/border_property.dart';
import 'package:flutter_window/windows.dart';
void main() {
runApp(const ToolmanApplication());
}
class ToolmanApplication extends StatefulWidget {
const ToolmanApplication({Key? key}) : super(key: key);
[@override](/user/override)
State<ToolmanApplication> createState() => _ToolmanApplicationState();
}
class _ToolmanApplicationState extends State<ToolmanApplication> {
[@override](/user/override)
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
brightness: Brightness.dark,
primaryColor: Colors.blue,
),
home: Scaffold(
body: LayoutBuilder(
builder: (context, constraints) {
return SizedBox(
width: constraints.maxWidth,
height: constraints.maxHeight,
// color: Colors.black,
child: Stack(
children: const [
Windows(
draggable: false, // 是否可拖动
border: BorderProperty.onlyThickness(3), // 边框厚度
height: 500, // 窗口高度
width: 500, // 窗口宽度
body: Text('Emulates the operating system window, which can be zoomed and dragged'), // 窗口主体内容
index: 1, // 窗口组件索引(预留)
position: Offset(50, 50), // 窗口偏移值
)
],
),
);
},
),
),
);
}
}
更多关于Flutter窗口管理插件flutter_window的使用的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复