Flutter Windows应用程序是否可以一直以全屏模式运行?调整窗口大小会导致元素无法正确呈现,从而导致应用程序崩溃。为了防止用户调整屏幕大小,我想禁用它。有没有办法让应用程序在 Windows 上始终以全屏模式打开?
最佳答案
在 pubspec.yaml
中添加这行代码
dependencies:
window_size:
git:
# url: git://github.com/google/flutter-desktop-embedding.git
url: https://github.com/google/flutter-desktop-embedding
path: plugins/window_size
然后在main.dart
中添加这段代码
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:window_size/window_size.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isWindows) {
setWindowMaxSize(Size(1100, 710));
setWindowMinSize(const Size(1100, 710));
Future<Null>.delayed(Duration(seconds: 0), () {
setWindowFrame(
Rect.fromCenter(center: Offset(650, 350), width: 1000, height: 710));
});
}
runApp(
(MySplashApp()),
);
}
关于flutter - 是否可以让 Flutter Windows 应用程序保持全屏显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72299717/