0
  • window.innerHeight
  • window.innerWidth

gives you the size of the window in "CSS pixel" not in real ones.

To develop a responsive application we need to know the real size of the screen to adapt the behavior of the application.

The solution in the Javascript world doesn't seem good enough

How can we do that properly in Dart?

Community
  • 1
  • 1
Gérald Reinhart
  • 3,101
  • 1
  • 13
  • 14
  • This is not really a Dart question. I guess you can increase your chances for getting a good answer by adding other labels like CSS or JavaScript. If you know how to do it in JS it's probably the same or similar in Dart. – Günter Zöchbauer Jan 06 '15 at 14:49
  • There are some answers on the Javascript side. I just wanted to do it in pure Dart if possible. – Gérald Reinhart Jan 06 '15 at 14:54
  • You could add the JS code to your question or at least link to the code that shows what you try to accomplish. – Günter Zöchbauer Jan 06 '15 at 14:56

2 Answers2

2

If you can't do it in JavaScript you can't do it in Dart neither. This is not a Dart limitation but a browser limitation. If the browser API doesn't provide this information you are out of luck.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • https://api.dartlang.org/apidocs/channels/be/dartdoc-viewer/dart:html.Window#id_devicePixelRatio : window.devicePixelRatio do you know this one ? For the moment, it's always a null value but it can be a starting point. – Gérald Reinhart Jan 23 '15 at 20:22
  • Also only relative information http://stackoverflow.com/questions/8785643/what-exactly-is-device-pixel-ratio – Günter Zöchbauer Jan 23 '15 at 22:13
1

You can't get the real screen size because there are no information provided to you that could give you about he physical size.

What's wrong about using pixel width/height and scaling up according to them?

Robert
  • 5,484
  • 1
  • 22
  • 35
  • a small mobile can have a very good resolution so the fact that width/height is high do not tell you that the real screen is big. for a small screen you need big button so that the user can actually reach them with its finger. – Gérald Reinhart Jan 06 '15 at 20:09