screenHeight property
double
get
screenHeight
Get the logical screen height multiplied by this number.
Initialization requirements:
- Recommended: call
FlutterSExtensions.update(context)in yourMaterialApp.builderto keep values fresh across hot reloads. - Lazy init: if no explicit init has occurred, a first view is used
from
WidgetsBinding.instance.platformDispatcher.views. This throws when no view is available (e.g., very early or certain tests).
Usage example in layout:
// In a news app header: take 90% of screen height
SizedBox(height: 0.9.screenHeight);
Error handling:
- Throws
StateErrorif the extension cannot be initialized (no binding or no available view). Ensure the app is running and initialized.
Value of this should be between 0 and 1.
Implementation
double get screenHeight {
final mq = FlutterSExtensions.mediaQuery();
return this * mq.size.height;
}