移动到屏幕顶部时如何使 Flutter 桌面应用程序全屏显示
How to make flutter desktop app goes fullscreen when move to top of the screen
当我将我的应用移动到屏幕顶部时
我想让它看起来像这样然后文件资源管理器进入全屏
解决方法:
只需将 WS_OVERLAPPEDWINDOW 添加到 win32_window.cpp
中的 window_class
您可以使用 windows_manager 包。将此代码添加到您的 main.dart:
import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Must add this line.
await windowManager.ensureInitialized();
// Use it only after calling `hiddenWindowAtLaunch`
windowManager.waitUntilReadyToShow().then((_) async{
// Hide window title bar
await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
await windowManager.setSize(Size(800, 600));
await windowManager.center();
await windowManager.show();
await windowManager.setSkipTaskbar(false);
});
runApp(MyApp());
}
当我将我的应用移动到屏幕顶部时
我想让它看起来像这样然后文件资源管理器进入全屏
解决方法: 只需将 WS_OVERLAPPEDWINDOW 添加到 win32_window.cpp
中的 window_class您可以使用 windows_manager 包。将此代码添加到您的 main.dart:
import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Must add this line.
await windowManager.ensureInitialized();
// Use it only after calling `hiddenWindowAtLaunch`
windowManager.waitUntilReadyToShow().then((_) async{
// Hide window title bar
await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
await windowManager.setSize(Size(800, 600));
await windowManager.center();
await windowManager.show();
await windowManager.setSkipTaskbar(false);
});
runApp(MyApp());
}