1

WidgetsBinding.instance.window.physicalSize.width / WidgetsBinding.instance.window.physicalSize.height; is 1024.0*1898.0,

and DesktopWindow.getWindowSize(); is Size(0.0, 0.0)

on a 4K monitor.

How can I get the real screen size? (should be 2160*3840)

derChris
  • 726
  • 8
  • 19

3 Answers3

4

Currently getting the screen size requires a plugin, such as window_size.

With window_size, getScreenList() or getCurrentScreen() will give you screen information, including size.

smorgan
  • 20,228
  • 3
  • 47
  • 55
  • The plugin is currently not available on pub.dev, so add it to your pubspec.yaml file like this: https://stackoverflow.com/questions/54022704/how-to-add-a-package-from-github-in-flutter – snap Sep 03 '22 at 04:25
  • The readme links to instructions for including it. – smorgan Sep 03 '22 at 22:01
2

You can use Media Query

MediaQuery.of(context).size.height
Will
  • 445
  • 2
  • 12
  • MediaQuery.of(context).size.height will tells me the height of the window but not of the screen. But I want to know the dimensions of the Screen/Monitor. – derChris Nov 17 '21 at 14:15
  • @derChris the browser does not expose this attribute. It is a breach of privacy to yank these values from the OS unless it is absolutely nescessary, which it isn't for a browser. It should be possible in native applications. – Can H. Tartanoglu Oct 20 '22 at 15:03
0

you can try screen_retriever plugin。

Display primaryDisplay = await screenRetriever.getPrimaryDisplay();
debugPrint("primaryDisplay.size: ${primaryDisplay.size}");
debugPrint("primaryDisplay.visibleSize: ${primaryDisplay.visibleSize}");
Qian
  • 41
  • 3