MediaQueryData.fromWindow constructor Null safety

MediaQueryData.fromWindow(
  1. FlutterView 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.FlutterView window)
  : size = window.physicalSize / window.devicePixelRatio,
    devicePixelRatio = window.devicePixelRatio,
    textScaleFactor = window.platformDispatcher.textScaleFactor,
    platformBrightness = window.platformDispatcher.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.platformDispatcher.accessibilityFeatures.accessibleNavigation,
    invertColors = window.platformDispatcher.accessibilityFeatures.invertColors,
    disableAnimations = window.platformDispatcher.accessibilityFeatures.disableAnimations,
    boldText = window.platformDispatcher.accessibilityFeatures.boldText,
    highContrast = window.platformDispatcher.accessibilityFeatures.highContrast,
    alwaysUse24HourFormat = window.platformDispatcher.alwaysUse24HourFormat,
    navigationMode = NavigationMode.traditional,
    gestureSettings = DeviceGestureSettings.fromWindow(window),
    displayFeatures = window.displayFeatures;