Reputation: 637
I am building a flutter web app, and I would like to know the width of the device the app is running on, not the window. Is this possible? Thank you!
Upvotes: 0
Views: 1138
Reputation: 857
You can get it without access to BuildContext
like this:
final double width = window.physicalSize.width / window.devicePixelRatio;
final double height = window.physicalSize.height / window.devicePixelRatio;
Make sure you import dart:ui
, not the html library.
Upvotes: 4