copyWith method

MediaQueryData copyWith({
  1. Size? size,
  2. double? devicePixelRatio,
  3. @Deprecated('Use textScaler instead. ' 'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. ' 'This feature was deprecated after v3.12.0-2.0.pre.') double? textScaleFactor,
  4. TextScaler? textScaler,
  5. Brightness? platformBrightness,
  6. EdgeInsets? padding,
  7. EdgeInsets? viewPadding,
  8. EdgeInsets? viewInsets,
  9. EdgeInsets? systemGestureInsets,
  10. bool? alwaysUse24HourFormat,
  11. bool? highContrast,
  12. bool? onOffSwitchLabels,
  13. bool? disableAnimations,
  14. bool? invertColors,
  15. bool? accessibleNavigation,
  16. bool? boldText,
  17. NavigationMode? navigationMode,
  18. DeviceGestureSettings? gestureSettings,
  19. List<DisplayFeature>? displayFeatures,
  20. bool? supportsShowingSystemContextMenu,
})

Creates a copy of this media query data but with the given fields replaced with the new values.

The textScaler parameter and textScaleFactor parameter must not be both specified.

Implementation

MediaQueryData copyWith({
  Size? size,
  double? devicePixelRatio,
  @Deprecated(
    'Use textScaler instead. '
    'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. '
    'This feature was deprecated after v3.12.0-2.0.pre.',
  )
  double? textScaleFactor,
  TextScaler? textScaler,
  Brightness? platformBrightness,
  EdgeInsets? padding,
  EdgeInsets? viewPadding,
  EdgeInsets? viewInsets,
  EdgeInsets? systemGestureInsets,
  bool? alwaysUse24HourFormat,
  bool? highContrast,
  bool? onOffSwitchLabels,
  bool? disableAnimations,
  bool? invertColors,
  bool? accessibleNavigation,
  bool? boldText,
  NavigationMode? navigationMode,
  DeviceGestureSettings? gestureSettings,
  List<ui.DisplayFeature>? displayFeatures,
  bool? supportsShowingSystemContextMenu,
}) {
  assert(textScaleFactor == null || textScaler == null);
  if (textScaleFactor != null) {
    textScaler ??= TextScaler.linear(textScaleFactor);
  }
  return MediaQueryData(
    size: size ?? this.size,
    devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio,
    textScaler: textScaler ?? this.textScaler,
    platformBrightness: platformBrightness ?? this.platformBrightness,
    padding: padding ?? this.padding,
    viewPadding: viewPadding ?? this.viewPadding,
    viewInsets: viewInsets ?? this.viewInsets,
    systemGestureInsets: systemGestureInsets ?? this.systemGestureInsets,
    alwaysUse24HourFormat: alwaysUse24HourFormat ?? this.alwaysUse24HourFormat,
    invertColors: invertColors ?? this.invertColors,
    highContrast: highContrast ?? this.highContrast,
    onOffSwitchLabels: onOffSwitchLabels ?? this.onOffSwitchLabels,
    disableAnimations: disableAnimations ?? this.disableAnimations,
    accessibleNavigation: accessibleNavigation ?? this.accessibleNavigation,
    boldText: boldText ?? this.boldText,
    navigationMode: navigationMode ?? this.navigationMode,
    gestureSettings: gestureSettings ?? this.gestureSettings,
    displayFeatures: displayFeatures ?? this.displayFeatures,
    supportsShowingSystemContextMenu: supportsShowingSystemContextMenu ?? this.supportsShowingSystemContextMenu,
  );
}