如何在颤动中设置macOS应用程序的默认大小? [英] How to set default size of macos app in flutter?
问题描述
我正在尝试用颤振构建一个 macOS 桌面应用程序.我希望应用程序是全角的,边缘到边缘的.但是,当我通过模拟器运行应用程序时,或者在构建之后,它总是启动大小为 800x600 的应用程序.
I am trying to build a macOS desktop app with flutter. I want the app to be full-width, edge-to-edge. However, when I run the app via the simulator, or after the build, it always launches the app with size 800x600.
我已将根容器的高度和宽度设置为 double.infinity.事实上,即使我将高度和宽度设置为 10.0,它总是以 800x600 启动应用程序.我是 Flutter 的新手,所以可能缺少一些基础知识.我遇到的大多数教程都在谈论构建一个移动应用程序,这从来都不是问题,因为应用程序总是以全宽启动.
I have set the height and width of the root container to double.infinity. In fact, even if I set the height and width to 10.0, it always launches the app with 800x600. I am new to flutter, so probably missing some fundamentals. Most tutorials I have come across talk about building a mobile app where this is never a problem because the app always launches to its full width.
这是我的整个测试应用代码:
Here is my entire test app code:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(color: Colors.white),
height: double.infinity,
width: double.infinity,
child: Center(
child: Text(
'Hello World',
textDirection: TextDirection.ltr,
style: TextStyle(
fontSize: 32, fontWeight: FontWeight.bold, color: Colors.black),
),
),
);
}
}
推荐答案
目前控制初始大小的唯一方法是在原生代码中(关注这些问题:1 和 2a> 找出变化的时间).您很可能希望在 macos/Runner/MainFlutterWindow.swift
中设置它.
Currently the only way to control the initial size is in native code (follow these issues: 1 and 2 to find out when that changes). You'd most likely want to set it in macos/Runner/MainFlutterWindow.swift
.
从您的描述中不清楚您是要启动全屏模式,还是只拥有屏幕客户区大小的标准窗口;所涉及的代码会有所不同,具体取决于您要完成的任务.
It's not clear from your description whether you want to launch into full-screen mode, or just have a standard window the size of the client area of the screen; the code involved would be different depending on which you are trying to accomplish.
这篇关于如何在颤动中设置macOS应用程序的默认大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!