Home > Software engineering >  Is it possible to keep Flutter windows app in fullscreen?
Is it possible to keep Flutter windows app in fullscreen?

Time:05-20

Is it possible to run the Flutter Windows app in full screen mode all the time? Window resizing causes the application to break by causing the elements to not render properly. To prevent the user from resizing the screen, I want to disable it. Is there a way to keep the application open in full screen all of the time on windows??

CodePudding user response:

Add this line of code in 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

then add this code in 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()),
  );
}
  • Related