size property Null safety
The size of the media in logical pixels (e.g, the size of the screen).
Logical pixels are roughly the same visual size across devices. Physical pixels are the size of the actual hardware pixels on the device. The number of physical pixels per logical pixel is described by the devicePixelRatio.
It is considered bad practice to cache and later use the size returned
MediaQuery.of(context).size. It will make the application non responsive
and might lead to unexpected behaviors.
For instance, during startup, especially in release mode, the first returned
size might be (0,0). The size will be updated when the native platform
reports the actual resolution.
See the article on Creating responsive and adaptive apps for an introduction.
- FlutterView.physicalSize, which returns the size in physical pixels.
final Size size;