MediaQueryData.fromWindow constructor Null safety

MediaQueryData.fromWindow(
  1. SingletonFlutterWindow window
)

Creates data for a media query based on the given window.

If you use this, you should ensure that you also register for notifications so that you can update your MediaQueryData when the window's metrics change. For example, see WidgetsBindingObserver.didChangeMetrics or dart:ui.PlatformDispatcher.onMetricsChanged.

Implementation

MediaQueryData.fromWindow(ui.SingletonFlutterWindow window)
  : size = window.physicalSize / window.devicePixelRatio,
    devicePixelRatio = window.devicePixelRatio,
    textScaleFactor = window.textScaleFactor,
    platformBrightness = window.platformBrightness,
    padding = EdgeInsets.fromWindowPadding(window.padding, window.devicePixelRatio),
    viewPadding = EdgeInsets.fromWindowPadding(window.viewPadding, window.devicePixelRatio),
    viewInsets = EdgeInsets.fromWindowPadding(window.viewInsets, window.devicePixelRatio),
    systemGestureInsets = EdgeInsets.fromWindowPadding(window.systemGestureInsets, window.devicePixelRatio),
    accessibleNavigation = window.accessibilityFeatures.accessibleNavigation,
    invertColors = window.accessibilityFeatures.invertColors,
    disableAnimations = window.accessibilityFeatures.disableAnimations,
    boldText = window.accessibilityFeatures.boldText,
    highContrast = window.accessibilityFeatures.highContrast,
    alwaysUse24HourFormat = window.alwaysUse24HourFormat,
    navigationMode = NavigationMode.traditional;