In the never-ending quest to reduce boilerplate and DRY up our code in Flutter, we have noticed that using the MediaQuery class can be a bit cumbersome, and it’s also missing a couple of key pieces of information.
The issues we see are:
- MediaQuery.of(context) is a bit verbose on its face
- Checking for orientation especially is too long:
bool isLandscape = MediaQuery.of(context).orientation == Orientation.landscape - There is no diagonal size parameter, so you can’t easily get the true screen size of the device, helpful for determining your form factor
- There is no way to get the size in inches, which can be useful when thinking about breakpoints (for most people, 4.5″ is easier to picture, than 720 logical pixels)
To that end, we have small Screen helper class, that we use across all our new projects:
Continue reading →







