Skip to content

[Linux] 启动无法实现设置的窗口大小 #230

@Aquarian-Age

Description

@Aquarian-Age

flutter build linux --debug
flutter build linux --release setWindowsSize()失效

Flutter (Channel stable, 3.3.4, on Debian GNU/Linux bookworm/sid 5.18.0-4-amd64
gcc (Debian 12.2.0-3) 12.2.0
cmake version 3.24.2

example

void setWindowsSize() async {
  WidgetsFlutterBinding.ensureInitialized();
  if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
    WidgetsFlutterBinding.ensureInitialized();
    await windowManager.ensureInitialized();

    WindowOptions windowOptions = const WindowOptions(
      size: Size(600, 850),
      minimumSize: Size(600, 850),
      center: true,
    );
    windowManager.waitUntilReadyToShow(windowOptions, () async {
      await windowManager.show();
      await windowManager.focus();
    });
  }
}

void main() async {
  setWindowsSize();
  runApp(const MyApp());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions