Bennett567
Bennett567

Reputation: 637

Is it possible to get the device sizes in flutter?

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

Answers (1)

Alexey Subbotin
Alexey Subbotin

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

Related Questions