skip to Main Content

I am not able to change the default output screen in flutter to a certain specific resolution. I am also unable to remove the minimize and maximize buttons in the default app bar.

in the image the resolution size is different I want it to be changed to 500 x 500 for all the screen sizes such as 14inchs, 17 inches laptop. If I am setting 1500×1200 in a 14-inch lap it is increased in a 17-inch lap for the same resolution instead I want 900×700 to be fixed for different screen sizes – how can I attain that?

Or is there any way I can fetch the physical screen size and set the percentage to 80% or 60% of the output screen? For desktop applications in Windows, Linux, and macOS, not Android, or iOS!

Referred with https://github.com/polilluminato/simple-flutter-resizewindow where a button is being set and calling different resolutions such as desktop to a certain resolution 1440×900 and tab and mobile so on but I want the default app bar size to be changed so that I could not achieve also disabling the minimize and maximizing button of the default app bar.

I am unable to do all these is for the web application, not Android, or iOS, by window_manager I am able to achieve this but for different lap inches the resolution change how to fix this also want to remove the minimize and maximize button

await windowManager.setSize(Size(800, 600));

Or desktop_window:

Size size = await DesktopWindow.getWindowSize();
DesktopWindow.setWindowSize(Size(800,600));
DesktopWindow.setFullScreen(true);

2

Answers


  1. Chosen as BEST ANSWER

    I was able to fix the above question i asked with the below code : my concern was it should reflect the same size on an 17inch lap and 14inch lap and it was fixed ..!!

    WidgetsFlutterBinding.ensureInitialized();
    

    doWhenWindowReady(() { WidgetsFlutterBinding.ensureInitialized() .renderView .automaticSystemUiAdjustment = false; final win = appWindow; const initialSize = Size(800, 600);

    win.minSize = initialSize;
    win.maxSize = initialSize;
    win.size = initialSize;
    win.alignment = Alignment.center;
    
    final screenSize = ui.window.physicalSize / ui.window.devicePixelRatio;
    final dx = (screenSize.width - initialSize.width) / 2;
    final dy = (screenSize.height - initialSize.height) / 2;
    win.position = Offset(dx, dy);
    
    win.show();
    

  2. To get Height and Width of the Screen try :

    double width = MediaQuery.of(context).size.width;
    double height = MediaQuery.of(context).size.height;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search