mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Squashed MediaQuery InheritedModel (#114459)
This commit is contained in:
parent
e57b7f4ea8
commit
73cb7c2fc5
@ -18,6 +18,17 @@
|
||||
# * Fixes in this file are from the Cupertino library. *
|
||||
version: 1
|
||||
transforms:
|
||||
# Changes made in https://github.com/flutter/flutter/pull/114459
|
||||
- title: "Migrate to 'boldTextOf'"
|
||||
date: 2022-10-28
|
||||
element:
|
||||
uris: ['widgets.dart', 'material.dart', 'cupertino.dart']
|
||||
method: 'boldTextOverride'
|
||||
inClass: 'MediaQuery'
|
||||
changes:
|
||||
- kind: 'rename'
|
||||
newName: 'boldTextOf'
|
||||
|
||||
# Change made in https://github.com/flutter/flutter/pull/20649
|
||||
# TODO(Piinks): Add tests when `bulkApply:false` testing is supported, https://github.com/dart-lang/sdk/issues/44639
|
||||
- title: "Replace with 'CupertinoPopupSurface'"
|
||||
|
@ -25,6 +25,17 @@
|
||||
# * ThemeData: fix_theme_data.yaml
|
||||
version: 1
|
||||
transforms:
|
||||
# Changes made in https://github.com/flutter/flutter/pull/114459
|
||||
- title: "Migrate to 'boldTextOf'"
|
||||
date: 2022-10-28
|
||||
element:
|
||||
uris: ['widgets.dart', 'material.dart', 'cupertino.dart']
|
||||
method: 'boldTextOverride'
|
||||
inClass: 'MediaQuery'
|
||||
changes:
|
||||
- kind: 'rename'
|
||||
newName: 'boldTextOf'
|
||||
|
||||
# Changes made in https://github.com/flutter/flutter/pull/15303
|
||||
- title: "Replace 'child' with 'builder'"
|
||||
date: 2020-12-17
|
||||
|
@ -23,6 +23,17 @@
|
||||
# * ListWheelScrollView: fix_list_wheel_scroll_view.yaml
|
||||
version: 1
|
||||
transforms:
|
||||
# Changes made in https://github.com/flutter/flutter/pull/114459
|
||||
- title: "Migrate to 'boldTextOf'"
|
||||
date: 2022-10-28
|
||||
element:
|
||||
uris: ['widgets.dart', 'material.dart', 'cupertino.dart']
|
||||
method: 'boldTextOverride'
|
||||
inClass: 'MediaQuery'
|
||||
changes:
|
||||
- kind: 'rename'
|
||||
newName: 'boldTextOf'
|
||||
|
||||
# Changes made in https://github.com/flutter/flutter/pull/87839
|
||||
- title: "Migrate to 'disallowIndicator'"
|
||||
date: 2021-08-06
|
||||
|
@ -156,7 +156,7 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final double bottomPadding = MediaQuery.of(context).viewPadding.bottom;
|
||||
final double bottomPadding = MediaQuery.viewPaddingOf(context).bottom;
|
||||
|
||||
final Color backgroundColor = CupertinoDynamicColor.resolve(
|
||||
this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor,
|
||||
|
@ -994,7 +994,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
|
||||
}
|
||||
bool isHighContrastEnabled = false;
|
||||
if (_isHighContrastDependent) {
|
||||
isHighContrastEnabled = MediaQuery.maybeOf(context)?.highContrast ?? false;
|
||||
isHighContrastEnabled = MediaQuery.maybeHighContrastOf(context) ?? false;
|
||||
}
|
||||
|
||||
final CupertinoUserInterfaceLevelData level = _isInterfaceElevationDependent
|
||||
|
@ -493,7 +493,7 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
|
||||
// it.
|
||||
_ContextMenuLocation get _contextMenuLocation {
|
||||
final Rect childRect = _getRect(_childGlobalKey);
|
||||
final double screenWidth = MediaQuery.of(context).size.width;
|
||||
final double screenWidth = MediaQuery.sizeOf(context).width;
|
||||
|
||||
final double center = screenWidth / 2;
|
||||
final bool centerDividesChild = childRect.left < center
|
||||
@ -1311,7 +1311,7 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
Widget _buildChildAnimation(BuildContext context, Widget? child) {
|
||||
_lastScale = _getScale(
|
||||
widget.orientation,
|
||||
MediaQuery.of(context).size.height,
|
||||
MediaQuery.sizeOf(context).height,
|
||||
_moveAnimation.value.dy,
|
||||
);
|
||||
return Transform.scale(
|
||||
|
@ -158,12 +158,12 @@ class _CupertinoDesktopTextSelectionControlsToolbarState extends State<_Cupertin
|
||||
}
|
||||
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
final EdgeInsets mediaQueryPadding = MediaQuery.paddingOf(context);
|
||||
|
||||
final Offset midpointAnchor = Offset(
|
||||
clampDouble(widget.selectionMidpoint.dx - widget.globalEditableRegion.left,
|
||||
mediaQuery.padding.left,
|
||||
mediaQuery.size.width - mediaQuery.padding.right,
|
||||
mediaQueryPadding.left,
|
||||
MediaQuery.sizeOf(context).width - mediaQueryPadding.right,
|
||||
),
|
||||
widget.selectionMidpoint.dy - widget.globalEditableRegion.top,
|
||||
);
|
||||
@ -171,7 +171,7 @@ class _CupertinoDesktopTextSelectionControlsToolbarState extends State<_Cupertin
|
||||
final List<Widget> items = <Widget>[];
|
||||
final CupertinoLocalizations localizations = CupertinoLocalizations.of(context);
|
||||
final Widget onePhysicalPixelVerticalDivider =
|
||||
SizedBox(width: 1.0 / MediaQuery.of(context).devicePixelRatio);
|
||||
SizedBox(width: 1.0 / MediaQuery.devicePixelRatioOf(context));
|
||||
|
||||
void addToolbarButton(
|
||||
String text,
|
||||
|
@ -85,9 +85,8 @@ class CupertinoDesktopTextSelectionToolbar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
|
||||
final double paddingAbove = mediaQuery.padding.top + _kToolbarScreenPadding;
|
||||
final double paddingAbove = MediaQuery.paddingOf(context).top + _kToolbarScreenPadding;
|
||||
final Offset localAdjustment = Offset(_kToolbarScreenPadding, paddingAbove);
|
||||
|
||||
return Padding(
|
||||
|
@ -149,8 +149,8 @@ const double _kMaxRegularTextScaleFactor = 1.4;
|
||||
// Accessibility mode on iOS is determined by the text scale factor that the
|
||||
// user has selected.
|
||||
bool _isInAccessibilityMode(BuildContext context) {
|
||||
final MediaQueryData? data = MediaQuery.maybeOf(context);
|
||||
return data != null && data.textScaleFactor > _kMaxRegularTextScaleFactor;
|
||||
final double? factor = MediaQuery.maybeTextScaleFactorOf(context);
|
||||
return factor != null && factor > _kMaxRegularTextScaleFactor;
|
||||
}
|
||||
|
||||
/// An iOS-style alert dialog.
|
||||
@ -257,7 +257,7 @@ class CupertinoAlertDialog extends StatelessWidget {
|
||||
final Curve insetAnimationCurve;
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
final double textScaleFactor = MediaQuery.of(context).textScaleFactor;
|
||||
final double textScaleFactor = MediaQuery.textScaleFactorOf(context);
|
||||
|
||||
final List<Widget> children = <Widget>[
|
||||
if (title != null || content != null)
|
||||
@ -317,7 +317,7 @@ class CupertinoAlertDialog extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final CupertinoLocalizations localizations = CupertinoLocalizations.of(context);
|
||||
final bool isInAccessibilityMode = _isInAccessibilityMode(context);
|
||||
final double textScaleFactor = MediaQuery.of(context).textScaleFactor;
|
||||
final double textScaleFactor = MediaQuery.textScaleFactorOf(context);
|
||||
return CupertinoUserInterfaceLevel(
|
||||
data: CupertinoUserInterfaceLevelData.elevated,
|
||||
child: MediaQuery(
|
||||
@ -331,7 +331,7 @@ class CupertinoAlertDialog extends StatelessWidget {
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return AnimatedPadding(
|
||||
padding: MediaQuery.of(context).viewInsets +
|
||||
padding: MediaQuery.viewInsetsOf(context) +
|
||||
const EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0),
|
||||
duration: insetAnimationDuration,
|
||||
curve: insetAnimationCurve,
|
||||
@ -611,12 +611,12 @@ class CupertinoActionSheet extends StatelessWidget {
|
||||
if (cancelButton != null) _buildCancelButton(),
|
||||
];
|
||||
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
final double actionSheetWidth;
|
||||
if (orientation == Orientation.portrait) {
|
||||
actionSheetWidth = MediaQuery.of(context).size.width - (_kActionSheetEdgeHorizontalPadding * 2);
|
||||
actionSheetWidth = MediaQuery.sizeOf(context).width - (_kActionSheetEdgeHorizontalPadding * 2);
|
||||
} else {
|
||||
actionSheetWidth = MediaQuery.of(context).size.height - (_kActionSheetEdgeHorizontalPadding * 2);
|
||||
actionSheetWidth = MediaQuery.sizeOf(context).height - (_kActionSheetEdgeHorizontalPadding * 2);
|
||||
}
|
||||
|
||||
return SafeArea(
|
||||
@ -797,7 +797,7 @@ class _CupertinoDialogRenderWidget extends RenderObjectWidget {
|
||||
@override
|
||||
RenderObject createRenderObject(BuildContext context) {
|
||||
return _RenderCupertinoDialog(
|
||||
dividerThickness: _kDividerThickness / MediaQuery.of(context).devicePixelRatio,
|
||||
dividerThickness: _kDividerThickness / MediaQuery.devicePixelRatioOf(context),
|
||||
isInAccessibilityMode: _isInAccessibilityMode(context) && !isActionSheet,
|
||||
dividerColor: CupertinoDynamicColor.resolve(dividerColor, context),
|
||||
isActionSheet: isActionSheet,
|
||||
@ -1464,7 +1464,7 @@ class _CupertinoAlertActionSection extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
final double devicePixelRatio = MediaQuery.devicePixelRatioOf(context);
|
||||
|
||||
final List<Widget> interactiveButtons = <Widget>[];
|
||||
for (int i = 0; i < children.length; i += 1) {
|
||||
|
@ -347,7 +347,7 @@ class CupertinoListSection extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color dividerColor = CupertinoColors.separator.resolveFrom(context);
|
||||
final double dividerHeight = 1.0 / MediaQuery.of(context).devicePixelRatio;
|
||||
final double dividerHeight = 1.0 / MediaQuery.devicePixelRatioOf(context);
|
||||
|
||||
// Long divider is used for wrapping the top and bottom of rows.
|
||||
// Only used in CupertinoListSectionType.base mode.
|
||||
|
@ -174,7 +174,7 @@ class _CupertinoTextMagnifierState extends State<CupertinoTextMagnifier>
|
||||
CupertinoMagnifier.kMagnifierAboveFocalPoint),
|
||||
);
|
||||
|
||||
final Rect screenRect = Offset.zero & MediaQuery.of(context).size;
|
||||
final Rect screenRect = Offset.zero & MediaQuery.sizeOf(context);
|
||||
|
||||
// Adjust the magnifier position so that it never exists outside the horizontal
|
||||
// padding.
|
||||
|
@ -756,7 +756,7 @@ class _CupertinoSliverNavigationBarState extends State<CupertinoSliverNavigation
|
||||
actionsForegroundColor: CupertinoTheme.of(context).primaryColor,
|
||||
transitionBetweenRoutes: widget.transitionBetweenRoutes,
|
||||
heroTag: widget.heroTag,
|
||||
persistentHeight: _kNavBarPersistentHeight + MediaQuery.of(context).padding.top,
|
||||
persistentHeight: _kNavBarPersistentHeight + MediaQuery.paddingOf(context).top,
|
||||
alwaysShowMiddle: widget.alwaysShowMiddle && widget.middle != null,
|
||||
stretchConfiguration: widget.stretch ? OverScrollHeaderStretchConfiguration() : null,
|
||||
),
|
||||
@ -1104,7 +1104,7 @@ class _PersistentNavigationBar extends StatelessWidget {
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
height: _kNavBarPersistentHeight + MediaQuery.of(context).padding.top,
|
||||
height: _kNavBarPersistentHeight + MediaQuery.paddingOf(context).top,
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
child: paddedToolbar,
|
||||
@ -1772,7 +1772,7 @@ class _NavigationBarTransition extends StatelessWidget {
|
||||
// can actually be outside the linearly lerp'ed Rect in the middle of
|
||||
// the animation, such as the topLargeTitle.
|
||||
return SizedBox(
|
||||
height: math.max(heightTween.begin!, heightTween.end!) + MediaQuery.of(context).padding.top,
|
||||
height: math.max(heightTween.begin!, heightTween.end!) + MediaQuery.paddingOf(context).top,
|
||||
width: double.infinity,
|
||||
child: Stack(
|
||||
children: children,
|
||||
|
@ -690,8 +690,8 @@ class _CupertinoBackGestureDetectorState<T> extends State<_CupertinoBackGestureD
|
||||
// For devices with notches, the drag area needs to be larger on the side
|
||||
// that has the notch.
|
||||
double dragAreaWidth = Directionality.of(context) == TextDirection.ltr ?
|
||||
MediaQuery.of(context).padding.left :
|
||||
MediaQuery.of(context).padding.right;
|
||||
MediaQuery.paddingOf(context).left :
|
||||
MediaQuery.paddingOf(context).right;
|
||||
dragAreaWidth = max(dragAreaWidth, _kBackGestureWidth);
|
||||
return Stack(
|
||||
fit: StackFit.passthrough,
|
||||
|
@ -171,7 +171,7 @@ class _CupertinoScrollbarState extends RawScrollbarState<CupertinoScrollbar> {
|
||||
..mainAxisMargin = _kScrollbarMainAxisMargin
|
||||
..crossAxisMargin = _kScrollbarCrossAxisMargin
|
||||
..radius = _radius
|
||||
..padding = MediaQuery.of(context).padding
|
||||
..padding = MediaQuery.paddingOf(context)
|
||||
..minLength = _kScrollbarMinLength
|
||||
..minOverscrollLength = _kScrollbarMinOverscrollLength
|
||||
..scrollbarOrientation = widget.scrollbarOrientation;
|
||||
|
@ -1224,7 +1224,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
|
||||
}
|
||||
|
||||
final bool enabled = widget.enabled ?? true;
|
||||
final Offset cursorOffset = Offset(_iOSHorizontalCursorOffsetPixels / MediaQuery.of(context).devicePixelRatio, 0);
|
||||
final Offset cursorOffset = Offset(_iOSHorizontalCursorOffsetPixels / MediaQuery.devicePixelRatioOf(context), 0);
|
||||
final List<TextInputFormatter> formatters = <TextInputFormatter>[
|
||||
...?widget.inputFormatters,
|
||||
if (widget.maxLength != null)
|
||||
|
@ -260,14 +260,14 @@ class _CupertinoTextSelectionControlsToolbarState extends State<_CupertinoTextSe
|
||||
}
|
||||
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
final EdgeInsets mediaQueryPadding = MediaQuery.paddingOf(context);
|
||||
|
||||
// The toolbar should appear below the TextField when there is not enough
|
||||
// space above the TextField to show it, assuming there's always enough
|
||||
// space at the bottom in this case.
|
||||
final double anchorX = clampDouble(widget.selectionMidpoint.dx + widget.globalEditableRegion.left,
|
||||
_kArrowScreenPadding + mediaQuery.padding.left,
|
||||
mediaQuery.size.width - mediaQuery.padding.right - _kArrowScreenPadding,
|
||||
_kArrowScreenPadding + mediaQueryPadding.left,
|
||||
MediaQuery.sizeOf(context).width - mediaQueryPadding.right - _kArrowScreenPadding,
|
||||
);
|
||||
|
||||
final double topAmountInEditableRegion = widget.endpoints.first.point.dy - widget.textLineHeight;
|
||||
@ -289,7 +289,7 @@ class _CupertinoTextSelectionControlsToolbarState extends State<_CupertinoTextSe
|
||||
final List<Widget> items = <Widget>[];
|
||||
final CupertinoLocalizations localizations = CupertinoLocalizations.of(context);
|
||||
final Widget onePhysicalPixelVerticalDivider =
|
||||
SizedBox(width: 1.0 / MediaQuery.of(context).devicePixelRatio);
|
||||
SizedBox(width: 1.0 / MediaQuery.devicePixelRatioOf(context));
|
||||
|
||||
void addToolbarButton(
|
||||
String text,
|
||||
|
@ -53,7 +53,7 @@ typedef CupertinoToolbarBuilder = Widget Function(
|
||||
class _CupertinoToolbarButtonDivider extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(width: 1.0 / MediaQuery.of(context).devicePixelRatio);
|
||||
return SizedBox(width: 1.0 / MediaQuery.devicePixelRatioOf(context));
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,9 +132,9 @@ class CupertinoTextSelectionToolbar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
final EdgeInsets mediaQueryPadding = MediaQuery.paddingOf(context);
|
||||
|
||||
final double paddingAbove = mediaQuery.padding.top + _kToolbarScreenPadding;
|
||||
final double paddingAbove = mediaQueryPadding.top + _kToolbarScreenPadding;
|
||||
final double toolbarHeightNeeded = paddingAbove
|
||||
+ _kToolbarContentDistance
|
||||
+ _kToolbarHeight;
|
||||
@ -142,8 +142,8 @@ class CupertinoTextSelectionToolbar extends StatelessWidget {
|
||||
|
||||
// The arrow, which points to the anchor, has some margin so it can't get
|
||||
// too close to the horizontal edges of the screen.
|
||||
final double leftMargin = _kArrowScreenPadding + mediaQuery.padding.left;
|
||||
final double rightMargin = mediaQuery.size.width - mediaQuery.padding.right - _kArrowScreenPadding;
|
||||
final double leftMargin = _kArrowScreenPadding + mediaQueryPadding.left;
|
||||
final double rightMargin = MediaQuery.sizeOf(context).width - mediaQueryPadding.right - _kArrowScreenPadding;
|
||||
|
||||
final Offset anchorAboveAdjusted = Offset(
|
||||
clampDouble(anchorAbove.dx, leftMargin, rightMargin),
|
||||
@ -480,7 +480,7 @@ class _CupertinoTextSelectionToolbarContentState extends State<_CupertinoTextSel
|
||||
onPressed: _handlePreviousPage,
|
||||
text: '◀',
|
||||
),
|
||||
dividerWidth: 1.0 / MediaQuery.of(context).devicePixelRatio,
|
||||
dividerWidth: 1.0 / MediaQuery.devicePixelRatioOf(context),
|
||||
nextButton: CupertinoTextSelectionToolbarButton.text(
|
||||
onPressed: _handleNextPage,
|
||||
text: '▶',
|
||||
|
@ -87,7 +87,7 @@ class CupertinoTheme extends StatelessWidget {
|
||||
/// [MediaQueryData.platformBrightness] for descendant Cupertino widgets.
|
||||
static Brightness brightnessOf(BuildContext context) {
|
||||
final _InheritedCupertinoTheme? inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedCupertinoTheme>();
|
||||
return inheritedTheme?.theme.data.brightness ?? MediaQuery.of(context).platformBrightness;
|
||||
return inheritedTheme?.theme.data.brightness ?? MediaQuery.platformBrightnessOf(context);
|
||||
}
|
||||
|
||||
/// Retrieves the [Brightness] to use for descendant Cupertino widgets, based
|
||||
@ -107,7 +107,7 @@ class CupertinoTheme extends StatelessWidget {
|
||||
/// [MediaQuery] exists, instead of returning null.
|
||||
static Brightness? maybeBrightnessOf(BuildContext context) {
|
||||
final _InheritedCupertinoTheme? inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedCupertinoTheme>();
|
||||
return inheritedTheme?.theme.data.brightness ?? MediaQuery.maybeOf(context)?.platformBrightness;
|
||||
return inheritedTheme?.theme.data.brightness ?? MediaQuery.maybePlatformBrightnessOf(context);
|
||||
}
|
||||
|
||||
/// The widget below this widget in the tree.
|
||||
|
@ -976,7 +976,7 @@ const double _wideGutterSize = 24.0;
|
||||
const double _narrowGutterSize = 12.0;
|
||||
|
||||
double _getGutterSize(BuildContext context) =>
|
||||
MediaQuery.of(context).size.width >= _materialGutterThreshold ? _wideGutterSize : _narrowGutterSize;
|
||||
MediaQuery.sizeOf(context).width >= _materialGutterThreshold ? _wideGutterSize : _narrowGutterSize;
|
||||
|
||||
/// Signature for the builder callback used by [_MasterDetailFlow].
|
||||
typedef _MasterViewBuilder = Widget Function(BuildContext context, bool isLateralUI);
|
||||
@ -1463,7 +1463,7 @@ class _DetailView extends StatelessWidget {
|
||||
if (_arguments == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final double screenHeight = MediaQuery.of(context).size.height;
|
||||
final double screenHeight = MediaQuery.sizeOf(context).height;
|
||||
final double minHeight = (screenHeight - kToolbarHeight) / screenHeight;
|
||||
|
||||
return DraggableScrollableSheet(
|
||||
|
@ -239,7 +239,7 @@ class _ActionChipDefaultsM3 extends ChipThemeData {
|
||||
EdgeInsetsGeometry? get labelPadding => EdgeInsets.lerp(
|
||||
const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
clampDouble(MediaQuery.of(context).textScaleFactor - 1.0, 0.0, 1.0),
|
||||
clampDouble(MediaQuery.textScaleFactorOf(context) - 1.0, 0.0, 1.0),
|
||||
)!;
|
||||
}
|
||||
|
||||
|
@ -2097,7 +2097,7 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
|
||||
Widget build(BuildContext context) {
|
||||
assert(!widget.primary || debugCheckHasMediaQuery(context));
|
||||
final double bottomHeight = widget.bottom?.preferredSize.height ?? 0.0;
|
||||
final double topPadding = widget.primary ? MediaQuery.of(context).padding.top : 0.0;
|
||||
final double topPadding = widget.primary ? MediaQuery.paddingOf(context).top : 0.0;
|
||||
final double collapsedHeight = (widget.pinned && widget.floating && widget.bottom != null)
|
||||
? (widget.collapsedHeight ?? 0.0) + bottomHeight + topPadding
|
||||
: (widget.collapsedHeight ?? widget.toolbarHeight) + bottomHeight + topPadding;
|
||||
@ -2211,7 +2211,7 @@ class _ScrollUnderFlexibleSpace extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
late final ThemeData theme = Theme.of(context);
|
||||
final FlexibleSpaceBarSettings settings = context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>()!;
|
||||
final double topPadding = primary ? MediaQuery.of(context).viewPadding.top : 0;
|
||||
final double topPadding = primary ? MediaQuery.viewPaddingOf(context).top : 0;
|
||||
final double collapsedHeight = settings.minExtent - topPadding;
|
||||
final double scrollUnderHeight = settings.maxExtent - settings.minExtent;
|
||||
final _ScrollUnderFlexibleConfig config;
|
||||
|
@ -293,7 +293,7 @@ class _MaterialBannerState extends State<MaterialBanner> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData mediaQueryData = MediaQuery.of(context);
|
||||
final bool accessibleNavigation = MediaQuery.accessibleNavigationOf(context);
|
||||
|
||||
assert(widget.actions.isNotEmpty);
|
||||
|
||||
@ -399,7 +399,7 @@ class _MaterialBannerState extends State<MaterialBanner> {
|
||||
onDismiss: () {
|
||||
ScaffoldMessenger.of(context).removeCurrentMaterialBanner(reason: MaterialBannerClosedReason.dismiss);
|
||||
},
|
||||
child: mediaQueryData.accessibleNavigation
|
||||
child: accessibleNavigation
|
||||
? materialBanner
|
||||
: SlideTransition(
|
||||
position: slideOutAnimation,
|
||||
@ -408,7 +408,7 @@ class _MaterialBannerState extends State<MaterialBanner> {
|
||||
);
|
||||
|
||||
final Widget materialBannerTransition;
|
||||
if (mediaQueryData.accessibleNavigation) {
|
||||
if (accessibleNavigation) {
|
||||
materialBannerTransition = materialBanner;
|
||||
} else {
|
||||
materialBannerTransition = AnimatedBuilder(
|
||||
|
@ -607,8 +607,7 @@ class _Tile extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final MediaQueryData data = MediaQuery.of(context);
|
||||
if (data.orientation == Orientation.landscape && layout == BottomNavigationBarLandscapeLayout.linear) {
|
||||
if (MediaQuery.orientationOf(context) == Orientation.landscape && layout == BottomNavigationBarLandscapeLayout.linear) {
|
||||
return Align(
|
||||
heightFactor: 1,
|
||||
child: Row(
|
||||
@ -1114,7 +1113,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
|
||||
final BottomNavigationBarLandscapeLayout layout = widget.landscapeLayout
|
||||
?? bottomTheme.landscapeLayout
|
||||
?? BottomNavigationBarLandscapeLayout.spread;
|
||||
final double additionalBottomPadding = MediaQuery.of(context).viewPadding.bottom;
|
||||
final double additionalBottomPadding = MediaQuery.viewPaddingOf(context).bottom;
|
||||
|
||||
Color? backgroundColor;
|
||||
switch (_effectiveType) {
|
||||
@ -1180,14 +1179,13 @@ class _Bar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final MediaQueryData data = MediaQuery.of(context);
|
||||
Widget alignedChild = child;
|
||||
if (data.orientation == Orientation.landscape && layout == BottomNavigationBarLandscapeLayout.centered) {
|
||||
if (MediaQuery.orientationOf(context) == Orientation.landscape && layout == BottomNavigationBarLandscapeLayout.centered) {
|
||||
alignedChild = Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
heightFactor: 1,
|
||||
child: SizedBox(
|
||||
width: data.size.height,
|
||||
width: MediaQuery.sizeOf(context).height,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
@ -409,7 +409,6 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
assert(debugCheckHasMaterialLocalizations(context));
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
final String routeLabel = _getRouteLabel(localizations);
|
||||
|
||||
@ -436,7 +435,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
|
||||
// Disable the initial animation when accessible navigation is on so
|
||||
// that the semantics are added to the tree at the correct time.
|
||||
final double animationValue = animationCurve.transform(
|
||||
mediaQuery.accessibleNavigation ? 1.0 : widget.route.animation!.value,
|
||||
MediaQuery.accessibleNavigationOf(context) ? 1.0 : widget.route.animation!.value,
|
||||
);
|
||||
return Semantics(
|
||||
scopesRoute: true,
|
||||
|
@ -1158,7 +1158,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
|
||||
final EdgeInsetsGeometry defaultLabelPadding = EdgeInsets.lerp(
|
||||
const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
clampDouble(MediaQuery.of(context).textScaleFactor - 1.0, 0.0, 1.0),
|
||||
clampDouble(MediaQuery.textScaleFactorOf(context) - 1.0, 0.0, 1.0),
|
||||
)!;
|
||||
|
||||
final ThemeData theme = Theme.of(context);
|
||||
@ -2257,7 +2257,7 @@ class _ChipDefaultsM3 extends ChipThemeData {
|
||||
EdgeInsetsGeometry? get labelPadding => EdgeInsets.lerp(
|
||||
const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
clampDouble(MediaQuery.of(context).textScaleFactor - 1.0, 0.0, 1.0),
|
||||
clampDouble(MediaQuery.textScaleFactorOf(context) - 1.0, 0.0, 1.0),
|
||||
)!;
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ class _ChoiceChipDefaultsM3 extends ChipThemeData {
|
||||
EdgeInsetsGeometry? get labelPadding => EdgeInsets.lerp(
|
||||
const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
clampDouble(MediaQuery.of(context).textScaleFactor - 1.0, 0.0, 1.0),
|
||||
clampDouble(MediaQuery.textScaleFactorOf(context) - 1.0, 0.0, 1.0),
|
||||
)!;
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
|
||||
}
|
||||
|
||||
Size _dialogSize(BuildContext context) {
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
switch (_entryMode.value) {
|
||||
case DatePickerEntryMode.calendar:
|
||||
case DatePickerEntryMode.calendarOnly:
|
||||
@ -456,11 +456,11 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final ColorScheme colorScheme = theme.colorScheme;
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
final TextTheme textTheme = theme.textTheme;
|
||||
// Constrain the textScaleFactor to the largest supported value to prevent
|
||||
// layout issues.
|
||||
final double textScaleFactor = math.min(MediaQuery.of(context).textScaleFactor, 1.3);
|
||||
final double textScaleFactor = math.min(MediaQuery.textScaleFactorOf(context), 1.3);
|
||||
|
||||
final String dateText = localizations.formatMediumDate(_selectedDate.value);
|
||||
final Color onPrimarySurface = colorScheme.brightness == Brightness.light
|
||||
@ -1316,9 +1316,8 @@ class _DateRangePickerDialogState extends State<DateRangePickerDialog> with Rest
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
final Orientation orientation = mediaQuery.orientation;
|
||||
final double textScaleFactor = math.min(mediaQuery.textScaleFactor, 1.3);
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
final double textScaleFactor = math.min(MediaQuery.textScaleFactorOf(context), 1.3);
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
final ColorScheme colors = Theme.of(context).colorScheme;
|
||||
final Color onPrimarySurface = colors.brightness == Brightness.light
|
||||
@ -1367,7 +1366,7 @@ class _DateRangePickerDialogState extends State<DateRangePickerDialog> with Rest
|
||||
: localizations.dateRangePickerHelpText.toUpperCase()
|
||||
),
|
||||
);
|
||||
size = mediaQuery.size;
|
||||
size = MediaQuery.sizeOf(context);
|
||||
insetPadding = EdgeInsets.zero;
|
||||
shape = const RoundedRectangleBorder();
|
||||
elevation = 0;
|
||||
@ -1499,7 +1498,7 @@ class _CalendarRangePickerDialog extends StatelessWidget {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final ColorScheme colorScheme = theme.colorScheme;
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
final TextTheme textTheme = theme.textTheme;
|
||||
final Color headerForeground = colorScheme.brightness == Brightness.light
|
||||
? colorScheme.onPrimary
|
||||
@ -1539,7 +1538,7 @@ class _CalendarRangePickerDialog extends StatelessWidget {
|
||||
bottom: PreferredSize(
|
||||
preferredSize: const Size(double.infinity, 64),
|
||||
child: Row(children: <Widget>[
|
||||
SizedBox(width: MediaQuery.of(context).size.width < 360 ? 42 : 72),
|
||||
SizedBox(width: MediaQuery.sizeOf(context).width < 360 ? 42 : 72),
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
label: '$helpText $startDateText to $endDateText',
|
||||
@ -2017,7 +2016,7 @@ class _DayHeaders extends StatelessWidget {
|
||||
|
||||
return Container(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).orientation == Orientation.landscape
|
||||
maxWidth: MediaQuery.orientationOf(context) == Orientation.landscape
|
||||
? _maxCalendarWidthLandscape
|
||||
: _maxCalendarWidthPortrait,
|
||||
maxHeight: _monthItemRowHeight,
|
||||
@ -2469,7 +2468,7 @@ class _MonthItemState extends State<_MonthItem> {
|
||||
paddedDayItems.addAll(weekList);
|
||||
}
|
||||
|
||||
final double maxWidth = MediaQuery.of(context).orientation == Orientation.landscape
|
||||
final double maxWidth = MediaQuery.orientationOf(context) == Orientation.landscape
|
||||
? _maxCalendarWidthLandscape
|
||||
: _maxCalendarWidthPortrait;
|
||||
return Column(
|
||||
@ -2623,7 +2622,7 @@ class _InputDateRangePickerDialog extends StatelessWidget {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final ColorScheme colorScheme = theme.colorScheme;
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
final TextTheme textTheme = theme.textTheme;
|
||||
|
||||
final Color onPrimarySurfaceColor = colorScheme.brightness == Brightness.light
|
||||
|
@ -177,12 +177,11 @@ class _DesktopTextSelectionControlsToolbarState extends State<_DesktopTextSelect
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
|
||||
final EdgeInsets mediaQueryPadding = MediaQuery.paddingOf(context);
|
||||
final Offset midpointAnchor = Offset(
|
||||
clampDouble(widget.selectionMidpoint.dx - widget.globalEditableRegion.left,
|
||||
mediaQuery.padding.left,
|
||||
mediaQuery.size.width - mediaQuery.padding.right,
|
||||
mediaQueryPadding.left,
|
||||
MediaQuery.sizeOf(context).width - mediaQueryPadding.right,
|
||||
),
|
||||
widget.selectionMidpoint.dy - widget.globalEditableRegion.top,
|
||||
);
|
||||
|
@ -64,9 +64,8 @@ class DesktopTextSelectionToolbar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
|
||||
final double paddingAbove = mediaQuery.padding.top + _kToolbarScreenPadding;
|
||||
final double paddingAbove = MediaQuery.paddingOf(context).top + _kToolbarScreenPadding;
|
||||
final Offset localAdjustment = Offset(_kToolbarScreenPadding, paddingAbove);
|
||||
|
||||
return Padding(
|
||||
|
@ -217,7 +217,7 @@ class Dialog extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final DialogTheme dialogTheme = DialogTheme.of(context);
|
||||
final EdgeInsets effectivePadding = MediaQuery.of(context).viewInsets + (insetPadding ?? EdgeInsets.zero);
|
||||
final EdgeInsets effectivePadding = MediaQuery.viewInsetsOf(context) + (insetPadding ?? EdgeInsets.zero);
|
||||
final DialogTheme defaults = theme.useMaterial3
|
||||
? (_fullscreen ? _DialogFullscreenDefaultsM3(context) : _DialogDefaultsM3(context))
|
||||
: _DialogDefaultsM2(context);
|
||||
@ -642,7 +642,7 @@ class AlertDialog extends StatelessWidget {
|
||||
|
||||
// The paddingScaleFactor is used to adjust the padding of Dialog's
|
||||
// children.
|
||||
final double paddingScaleFactor = _paddingScaleFactor(MediaQuery.of(context).textScaleFactor);
|
||||
final double paddingScaleFactor = _paddingScaleFactor(MediaQuery.textScaleFactorOf(context));
|
||||
final TextDirection? textDirection = Directionality.maybeOf(context);
|
||||
|
||||
Widget? iconWidget;
|
||||
@ -1075,7 +1075,7 @@ class SimpleDialog extends StatelessWidget {
|
||||
|
||||
// The paddingScaleFactor is used to adjust the padding of Dialog
|
||||
// children.
|
||||
final double paddingScaleFactor = _paddingScaleFactor(MediaQuery.of(context).textScaleFactor);
|
||||
final double paddingScaleFactor = _paddingScaleFactor(MediaQuery.textScaleFactorOf(context));
|
||||
final TextDirection? textDirection = Directionality.maybeOf(context);
|
||||
|
||||
Widget? titleWidget;
|
||||
|
@ -382,11 +382,11 @@ class DrawerController extends StatefulWidget {
|
||||
/// drawer.
|
||||
///
|
||||
/// By default, the value used is 20.0 added to the padding edge of
|
||||
/// `MediaQuery.of(context).padding` that corresponds to [alignment].
|
||||
/// `MediaQuery.paddingOf(context)` that corresponds to [alignment].
|
||||
/// This ensures that the drag area for notched devices is not obscured. For
|
||||
/// example, if [alignment] is set to [DrawerAlignment.start] and
|
||||
/// `TextDirection.of(context)` is set to [TextDirection.ltr],
|
||||
/// 20.0 will be added to `MediaQuery.of(context).padding.left`.
|
||||
/// 20.0 will be added to `MediaQuery.paddingOf(context).left`.
|
||||
final double? edgeDragWidth;
|
||||
|
||||
/// Whether or not the drawer is opened or closed.
|
||||
@ -680,7 +680,6 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
||||
|
||||
Widget _buildDrawer(BuildContext context) {
|
||||
final bool drawerIsStart = widget.alignment == DrawerAlignment.start;
|
||||
final EdgeInsets padding = MediaQuery.of(context).padding;
|
||||
final TextDirection textDirection = Directionality.of(context);
|
||||
final bool isDesktop;
|
||||
switch (Theme.of(context).platform) {
|
||||
@ -698,6 +697,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
||||
|
||||
double? dragAreaWidth = widget.edgeDragWidth;
|
||||
if (widget.edgeDragWidth == null) {
|
||||
final EdgeInsets padding = MediaQuery.paddingOf(context);
|
||||
switch (textDirection) {
|
||||
case TextDirection.ltr:
|
||||
dragAreaWidth = _kEdgeDragWidth +
|
||||
|
@ -76,7 +76,7 @@ class DrawerHeader extends StatelessWidget {
|
||||
assert(debugCheckHasMaterial(context));
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final double statusBarHeight = MediaQuery.of(context).padding.top;
|
||||
final double statusBarHeight = MediaQuery.paddingOf(context).top;
|
||||
return Container(
|
||||
height: statusBarHeight + _kDrawerHeaderHeight,
|
||||
margin: margin,
|
||||
|
@ -1333,7 +1333,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
|
||||
// Similarly, we don't reduce the height of the button so much that its icon
|
||||
// would be clipped.
|
||||
double get _denseButtonHeight {
|
||||
final double textScaleFactor = MediaQuery.of(context).textScaleFactor;
|
||||
final double textScaleFactor = MediaQuery.textScaleFactorOf(context);
|
||||
final double fontSize = _textStyle!.fontSize ?? Theme.of(context).textTheme.titleMedium!.fontSize!;
|
||||
final double scaledFontSize = textScaleFactor * fontSize;
|
||||
return math.max(scaledFontSize, math.max(widget.iconSize, _kDenseButtonHeight));
|
||||
@ -1369,7 +1369,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
|
||||
bool get _enabled => widget.items != null && widget.items!.isNotEmpty && widget.onChanged != null;
|
||||
|
||||
Orientation _getOrientation(BuildContext context) {
|
||||
Orientation? result = MediaQuery.maybeOf(context)?.orientation;
|
||||
Orientation? result = MediaQuery.maybeOrientationOf(context);
|
||||
if (result == null) {
|
||||
// If there's no MediaQuery, then use the window aspect to determine
|
||||
// orientation.
|
||||
|
@ -252,7 +252,7 @@ class ElevatedButton extends ButtonStyleButton {
|
||||
/// each state, and "others" means all other states.
|
||||
///
|
||||
/// The `textScaleFactor` is the value of
|
||||
/// `MediaQuery.of(context).textScaleFactor` and the names of the
|
||||
/// `MediaQuery.textScaleFactorOf(context)` and the names of the
|
||||
/// EdgeInsets constructors and `EdgeInsetsGeometry.lerp` have been
|
||||
/// abbreviated for readability.
|
||||
///
|
||||
@ -394,7 +394,7 @@ EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
||||
const EdgeInsets.symmetric(horizontal: 16),
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
|
||||
MediaQuery.textScaleFactorOf(context),
|
||||
);
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@ class _ElevatedButtonWithIcon extends ElevatedButton {
|
||||
const EdgeInsetsDirectional.fromSTEB(12, 0, 16, 0),
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
const EdgeInsetsDirectional.fromSTEB(8, 0, 4, 0),
|
||||
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
|
||||
MediaQuery.textScaleFactorOf(context),
|
||||
);
|
||||
return super.defaultStyleOf(context).copyWith(
|
||||
padding: MaterialStatePropertyAll<EdgeInsetsGeometry>(scaledPadding),
|
||||
@ -516,7 +516,7 @@ class _ElevatedButtonWithIconChild extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double scale = MediaQuery.maybeOf(context)?.textScaleFactor ?? 1;
|
||||
final double scale = MediaQuery.textScaleFactorOf(context);
|
||||
final double gap = scale <= 1 ? 8 : lerpDouble(8, 4, math.min(scale - 1, 1))!;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -288,7 +288,7 @@ class FilledButton extends ButtonStyleButton {
|
||||
/// each state, and "others" means all other states.
|
||||
///
|
||||
/// The `textScaleFactor` is the value of
|
||||
/// `MediaQuery.of(context).textScaleFactor` and the names of the
|
||||
/// `MediaQuery.textScaleFactorOf(context)` and the names of the
|
||||
/// EdgeInsets constructors and `EdgeInsetsGeometry.lerp` have been
|
||||
/// abbreviated for readability.
|
||||
///
|
||||
@ -368,7 +368,7 @@ EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
||||
const EdgeInsets.symmetric(horizontal: 16),
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
|
||||
MediaQuery.textScaleFactorOf(context),
|
||||
);
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ class _FilledButtonWithIcon extends FilledButton {
|
||||
const EdgeInsetsDirectional.fromSTEB(12, 0, 16, 0),
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
const EdgeInsetsDirectional.fromSTEB(8, 0, 4, 0),
|
||||
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
|
||||
MediaQuery.textScaleFactorOf(context),
|
||||
);
|
||||
return super.defaultStyleOf(context).copyWith(
|
||||
padding: MaterialStatePropertyAll<EdgeInsetsGeometry>(scaledPadding),
|
||||
@ -487,7 +487,7 @@ class _FilledButtonWithIconChild extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double scale = MediaQuery.maybeOf(context)?.textScaleFactor ?? 1;
|
||||
final double scale = MediaQuery.textScaleFactorOf(context);
|
||||
// Adjust the gap based on the text scale factor. Start at 8, and lerp
|
||||
// to 4 based on how large the text is.
|
||||
final double gap = scale <= 1 ? 8 : lerpDouble(8, 4, math.min(scale - 1, 1))!;
|
||||
|
@ -267,7 +267,7 @@ class _FilterChipDefaultsM3 extends ChipThemeData {
|
||||
EdgeInsetsGeometry? get labelPadding => EdgeInsets.lerp(
|
||||
const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
clampDouble(MediaQuery.of(context).textScaleFactor - 1.0, 0.0, 1.0),
|
||||
clampDouble(MediaQuery.textScaleFactorOf(context) - 1.0, 0.0, 1.0),
|
||||
)!;
|
||||
}
|
||||
|
||||
|
@ -1018,7 +1018,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
||||
}
|
||||
|
||||
bool get _shouldShowFocus {
|
||||
final NavigationMode mode = MediaQuery.maybeOf(context)?.navigationMode ?? NavigationMode.traditional;
|
||||
final NavigationMode mode = MediaQuery.maybeNavigationModeOf(context) ?? NavigationMode.traditional;
|
||||
switch (mode) {
|
||||
case NavigationMode.traditional:
|
||||
return enabled && _hasFocus;
|
||||
@ -1166,7 +1166,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
||||
}
|
||||
|
||||
bool get _canRequestFocus {
|
||||
final NavigationMode mode = MediaQuery.maybeOf(context)?.navigationMode ?? NavigationMode.traditional;
|
||||
final NavigationMode mode = MediaQuery.maybeNavigationModeOf(context) ?? NavigationMode.traditional;
|
||||
switch (mode) {
|
||||
case NavigationMode.traditional:
|
||||
return enabled && widget.canRequestFocus;
|
||||
|
@ -310,7 +310,7 @@ class _InputChipDefaultsM3 extends ChipThemeData {
|
||||
EdgeInsetsGeometry? get labelPadding => EdgeInsets.lerp(
|
||||
const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
clampDouble(MediaQuery.of(context).textScaleFactor - 1.0, 0.0, 1.0),
|
||||
clampDouble(MediaQuery.textScaleFactorOf(context) - 1.0, 0.0, 1.0),
|
||||
)!;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ class _TextMagnifierState extends State<TextMagnifier> {
|
||||
void _determineMagnifierPositionAndFocalPoint() {
|
||||
final MagnifierInfo selectionInfo =
|
||||
widget.magnifierInfo.value;
|
||||
final Rect screenRect = Offset.zero & MediaQuery.of(context).size;
|
||||
final Rect screenRect = Offset.zero & MediaQuery.sizeOf(context);
|
||||
|
||||
// Since by default we draw at the top left corner, this offset
|
||||
// shifts the magnifier so we draw at the center, and then also includes
|
||||
|
@ -315,7 +315,7 @@ class _MenuAnchorState extends State<MenuAnchor> {
|
||||
_position?.isScrollingNotifier.removeListener(_handleScroll);
|
||||
_position = Scrollable.maybeOf(context)?.position;
|
||||
_position?.isScrollingNotifier.addListener(_handleScroll);
|
||||
final Size newSize = MediaQuery.of(context).size;
|
||||
final Size newSize = MediaQuery.sizeOf(context);
|
||||
if (_viewSize != null && newSize != _viewSize) {
|
||||
// Close the menus if the view changes size.
|
||||
_root._close();
|
||||
@ -3746,7 +3746,7 @@ class _MenuButtonDefaultsM3 extends ButtonStyle {
|
||||
const EdgeInsets.symmetric(horizontal: 12),
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
|
||||
MediaQuery.maybeTextScaleFactorOf(context) ?? 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -994,7 +994,7 @@ class _ClampTextScaleFactor extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
textScaleFactor: clampDouble(MediaQuery.of(context).textScaleFactor,
|
||||
textScaleFactor: clampDouble(MediaQuery.textScaleFactorOf(context),
|
||||
0.0,
|
||||
upperLimit,
|
||||
),
|
||||
|
@ -351,7 +351,7 @@ EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
||||
const EdgeInsets.symmetric(horizontal: 16),
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
|
||||
MediaQuery.textScaleFactorOf(context),
|
||||
);
|
||||
}
|
||||
|
||||
@ -437,7 +437,7 @@ class _OutlinedButtonWithIconChild extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double scale = MediaQuery.maybeOf(context)?.textScaleFactor ?? 1;
|
||||
final double scale = MediaQuery.textScaleFactorOf(context);
|
||||
final double gap = scale <= 1 ? 8 : lerpDouble(8, 4, math.min(scale - 1, 1))!;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -1292,7 +1292,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
|
||||
}
|
||||
|
||||
bool get _canRequestFocus {
|
||||
final NavigationMode mode = MediaQuery.maybeOf(context)?.navigationMode ?? NavigationMode.traditional;
|
||||
final NavigationMode mode = MediaQuery.maybeNavigationModeOf(context) ?? NavigationMode.traditional;
|
||||
switch (mode) {
|
||||
case NavigationMode.traditional:
|
||||
return widget.enabled;
|
||||
|
@ -619,7 +619,7 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
|
||||
// This size is used as the max bounds for the painting of the value
|
||||
// indicators. It must be kept in sync with the function with the same name
|
||||
// in slider.dart.
|
||||
Size screenSize() => MediaQuery.of(context).size;
|
||||
Size screenSize() => MediaQuery.sizeOf(context);
|
||||
|
||||
return CompositedTransformTarget(
|
||||
link: _layerLink,
|
||||
@ -628,7 +628,7 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
|
||||
divisions: widget.divisions,
|
||||
labels: widget.labels,
|
||||
sliderTheme: sliderTheme,
|
||||
textScaleFactor: MediaQuery.of(context).textScaleFactor,
|
||||
textScaleFactor: MediaQuery.textScaleFactorOf(context),
|
||||
screenSize: screenSize(),
|
||||
onChanged: (widget.onChanged != null) && (widget.max > widget.min) ? _handleChanged : null,
|
||||
onChangeStart: widget.onChangeStart != null ? _handleDragStart : null,
|
||||
@ -704,7 +704,7 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
|
||||
textDirection: Directionality.of(context),
|
||||
semanticFormatterCallback: semanticFormatterCallback,
|
||||
platform: Theme.of(context).platform,
|
||||
gestureSettings: MediaQuery.of(context).gestureSettings,
|
||||
gestureSettings: MediaQuery.gestureSettingsOf(context),
|
||||
);
|
||||
}
|
||||
|
||||
@ -726,7 +726,7 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
|
||||
..textDirection = Directionality.of(context)
|
||||
..semanticFormatterCallback = semanticFormatterCallback
|
||||
..platform = Theme.of(context).platform
|
||||
..gestureSettings = MediaQuery.of(context).gestureSettings;
|
||||
..gestureSettings = MediaQuery.gestureSettingsOf(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,18 +191,18 @@ class ScaffoldMessengerState extends State<ScaffoldMessenger> with TickerProvide
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
final bool accessibleNavigation = MediaQuery.accessibleNavigationOf(context);
|
||||
// If we transition from accessible navigation to non-accessible navigation
|
||||
// and there is a SnackBar that would have timed out that has already
|
||||
// completed its timer, dismiss that SnackBar. If the timer hasn't finished
|
||||
// yet, let it timeout as normal.
|
||||
if ((_accessibleNavigation ?? false)
|
||||
&& !mediaQuery.accessibleNavigation
|
||||
&& !accessibleNavigation
|
||||
&& _snackBarTimer != null
|
||||
&& !_snackBarTimer!.isActive) {
|
||||
hideCurrentSnackBar(reason: SnackBarClosedReason.timeout);
|
||||
}
|
||||
_accessibleNavigation = mediaQuery.accessibleNavigation;
|
||||
_accessibleNavigation = accessibleNavigation;
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@ -568,8 +568,7 @@ class ScaffoldMessengerState extends State<ScaffoldMessenger> with TickerProvide
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
_accessibleNavigation = mediaQuery.accessibleNavigation;
|
||||
_accessibleNavigation = MediaQuery.accessibleNavigationOf(context);
|
||||
|
||||
if (_snackBars.isNotEmpty) {
|
||||
final ModalRoute<dynamic>? route = ModalRoute.of(context);
|
||||
@ -582,8 +581,7 @@ class ScaffoldMessengerState extends State<ScaffoldMessenger> with TickerProvide
|
||||
_snackBarController!.status == AnimationStatus.completed,
|
||||
);
|
||||
// Look up MediaQuery again in case the setting changed.
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
if (mediaQuery.accessibleNavigation && snackBar.action != null) {
|
||||
if (snackBar.action != null && MediaQuery.accessibleNavigationOf(context)) {
|
||||
return;
|
||||
}
|
||||
hideCurrentSnackBar(reason: SnackBarClosedReason.timeout);
|
||||
@ -1824,11 +1822,11 @@ class Scaffold extends StatefulWidget {
|
||||
/// drawer.
|
||||
///
|
||||
/// By default, the value used is 20.0 added to the padding edge of
|
||||
/// `MediaQuery.of(context).padding` that corresponds to the surrounding
|
||||
/// `MediaQuery.paddingOf(context)` that corresponds to the surrounding
|
||||
/// [TextDirection]. This ensures that the drag area for notched devices is
|
||||
/// not obscured. For example, if `TextDirection.of(context)` is set to
|
||||
/// [TextDirection.ltr], 20.0 will be added to
|
||||
/// `MediaQuery.of(context).padding.left`.
|
||||
/// `MediaQuery.paddingOf(context).left`.
|
||||
final double? drawerEdgeDragWidth;
|
||||
|
||||
/// Determines if the [Scaffold.drawer] can be opened with a drag
|
||||
@ -2761,7 +2759,6 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
assert(debugCheckHasDirectionality(context));
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
final TextDirection textDirection = Directionality.of(context);
|
||||
|
||||
@ -2796,7 +2793,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
||||
}
|
||||
|
||||
if (widget.appBar != null) {
|
||||
final double topPadding = widget.primary ? mediaQuery.padding.top : 0.0;
|
||||
final double topPadding = widget.primary ? MediaQuery.paddingOf(context).top : 0.0;
|
||||
_appBarMaxHeight = AppBar.preferredHeightFor(context, widget.appBar!.preferredSize) + topPadding;
|
||||
assert(_appBarMaxHeight! >= 0.0 && _appBarMaxHeight!.isFinite);
|
||||
_addIfNonNull(
|
||||
@ -2973,14 +2970,14 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
||||
}
|
||||
|
||||
// The minimum insets for contents of the Scaffold to keep visible.
|
||||
final EdgeInsets minInsets = mediaQuery.padding.copyWith(
|
||||
bottom: _resizeToAvoidBottomInset ? mediaQuery.viewInsets.bottom : 0.0,
|
||||
final EdgeInsets minInsets = MediaQuery.paddingOf(context).copyWith(
|
||||
bottom: _resizeToAvoidBottomInset ? MediaQuery.viewInsetsOf(context).bottom : 0.0,
|
||||
);
|
||||
|
||||
// The minimum viewPadding for interactive elements positioned by the
|
||||
// Scaffold to keep within safe interactive areas.
|
||||
final EdgeInsets minViewPadding = mediaQuery.viewPadding.copyWith(
|
||||
bottom: _resizeToAvoidBottomInset && mediaQuery.viewInsets.bottom != 0.0 ? 0.0 : null,
|
||||
final EdgeInsets minViewPadding = MediaQuery.viewPaddingOf(context).copyWith(
|
||||
bottom: _resizeToAvoidBottomInset && MediaQuery.viewInsetsOf(context).bottom != 0.0 ? 0.0 : null,
|
||||
);
|
||||
|
||||
// extendBody locked when keyboard is open
|
||||
|
@ -427,7 +427,7 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> {
|
||||
..crossAxisMargin = _scrollbarTheme.crossAxisMargin ?? (_useAndroidScrollbar ? 0.0 : _kScrollbarMargin)
|
||||
..mainAxisMargin = _scrollbarTheme.mainAxisMargin ?? 0.0
|
||||
..minLength = _scrollbarTheme.minThumbLength ?? _kScrollbarMinLength
|
||||
..padding = MediaQuery.of(context).padding
|
||||
..padding = MediaQuery.paddingOf(context)
|
||||
..scrollbarOrientation = widget.scrollbarOrientation
|
||||
..ignorePointer = !enableGestures;
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ class _SelectableTextState extends State<SelectableText> implements TextSelectio
|
||||
cursorColor = widget.cursorColor ?? selectionStyle.cursorColor ?? cupertinoTheme.primaryColor;
|
||||
selectionColor = selectionStyle.selectionColor ?? cupertinoTheme.primaryColor.withOpacity(0.40);
|
||||
cursorRadius ??= const Radius.circular(2.0);
|
||||
cursorOffset = Offset(iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0);
|
||||
cursorOffset = Offset(iOSHorizontalOffset / MediaQuery.devicePixelRatioOf(context), 0);
|
||||
break;
|
||||
|
||||
case TargetPlatform.macOS:
|
||||
@ -671,7 +671,7 @@ class _SelectableTextState extends State<SelectableText> implements TextSelectio
|
||||
cursorColor = widget.cursorColor ?? selectionStyle.cursorColor ?? cupertinoTheme.primaryColor;
|
||||
selectionColor = selectionStyle.selectionColor ?? cupertinoTheme.primaryColor.withOpacity(0.40);
|
||||
cursorRadius ??= const Radius.circular(2.0);
|
||||
cursorOffset = Offset(iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0);
|
||||
cursorOffset = Offset(iOSHorizontalOffset / MediaQuery.devicePixelRatioOf(context), 0);
|
||||
break;
|
||||
|
||||
case TargetPlatform.android:
|
||||
@ -700,7 +700,7 @@ class _SelectableTextState extends State<SelectableText> implements TextSelectio
|
||||
if (effectiveTextStyle == null || effectiveTextStyle.inherit) {
|
||||
effectiveTextStyle = defaultTextStyle.style.merge(widget.style ?? _controller._textSpan.style);
|
||||
}
|
||||
if (MediaQuery.boldTextOverride(context)) {
|
||||
if (MediaQuery.boldTextOf(context)) {
|
||||
effectiveTextStyle = effectiveTextStyle.merge(const TextStyle(fontWeight: FontWeight.bold));
|
||||
}
|
||||
final Widget child = RepaintBoundary(
|
||||
|
@ -826,7 +826,7 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
|
||||
// This size is used as the max bounds for the painting of the value
|
||||
// indicators It must be kept in sync with the function with the same name
|
||||
// in range_slider.dart.
|
||||
Size screenSize() => MediaQuery.of(context).size;
|
||||
Size screenSize() => MediaQuery.sizeOf(context);
|
||||
|
||||
VoidCallback? handleDidGainAccessibilityFocus;
|
||||
switch (theme.platform) {
|
||||
@ -847,7 +847,7 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
|
||||
}
|
||||
|
||||
final Map<ShortcutActivator, Intent> shortcutMap;
|
||||
switch (MediaQuery.of(context).navigationMode) {
|
||||
switch (MediaQuery.navigationModeOf(context)) {
|
||||
case NavigationMode.directional:
|
||||
shortcutMap = _directionalNavShortcutMap;
|
||||
break;
|
||||
@ -861,8 +861,8 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
|
||||
// This needs to be updated when accessibility
|
||||
// guidelines are available on the material specs page
|
||||
// https://m3.material.io/components/sliders/accessibility.
|
||||
? math.min(MediaQuery.of(context).textScaleFactor, 1.3)
|
||||
: MediaQuery.of(context).textScaleFactor;
|
||||
? math.min(MediaQuery.textScaleFactorOf(context), 1.3)
|
||||
: MediaQuery.textScaleFactorOf(context);
|
||||
|
||||
return Semantics(
|
||||
container: true,
|
||||
@ -994,7 +994,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
|
||||
platform: Theme.of(context).platform,
|
||||
hasFocus: hasFocus,
|
||||
hovering: hovering,
|
||||
gestureSettings: MediaQuery.of(context).gestureSettings,
|
||||
gestureSettings: MediaQuery.gestureSettingsOf(context),
|
||||
);
|
||||
}
|
||||
|
||||
@ -1018,7 +1018,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
|
||||
..platform = Theme.of(context).platform
|
||||
..hasFocus = hasFocus
|
||||
..hovering = hovering
|
||||
..gestureSettings = MediaQuery.of(context).gestureSettings;
|
||||
..gestureSettings = MediaQuery.gestureSettingsOf(context);
|
||||
// Ticker provider cannot change since there's a 1:1 relationship between
|
||||
// the _SliderRenderObjectWidget object and the _SliderState object.
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ class _SnackBarState extends State<SnackBar> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData mediaQueryData = MediaQuery.of(context);
|
||||
final bool accessibleNavigation = MediaQuery.accessibleNavigationOf(context);
|
||||
assert(widget.animation != null);
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final ColorScheme colorScheme = theme.colorScheme;
|
||||
@ -599,7 +599,7 @@ class _SnackBarState extends State<SnackBar> {
|
||||
|
||||
final EdgeInsets margin = widget.margin?.resolve(TextDirection.ltr) ?? snackBarTheme.insetPadding ?? defaults.insetPadding!;
|
||||
|
||||
final double snackBarWidth = widget.width ?? mediaQueryData.size.width - (margin.left + margin.right);
|
||||
final double snackBarWidth = widget.width ?? MediaQuery.sizeOf(context).width - (margin.left + margin.right);
|
||||
// Action and Icon will overflow to a new line if their width is greater
|
||||
// than one quarter of the total Snack Bar width.
|
||||
final bool actionLineOverflow =
|
||||
@ -675,7 +675,7 @@ class _SnackBarState extends State<SnackBar> {
|
||||
color: backgroundColor,
|
||||
child: Theme(
|
||||
data: effectiveTheme,
|
||||
child: mediaQueryData.accessibleNavigation || theme.useMaterial3
|
||||
child: accessibleNavigation || theme.useMaterial3
|
||||
? snackBar
|
||||
: FadeTransition(
|
||||
opacity: fadeOutAnimation,
|
||||
@ -723,7 +723,7 @@ class _SnackBarState extends State<SnackBar> {
|
||||
);
|
||||
|
||||
final Widget snackBarTransition;
|
||||
if (mediaQueryData.accessibleNavigation) {
|
||||
if (accessibleNavigation) {
|
||||
snackBarTransition = snackBar;
|
||||
} else if (isFloatingSnackBar && !theme.useMaterial3) {
|
||||
snackBarTransition = FadeTransition(
|
||||
|
@ -249,7 +249,7 @@ class TextButton extends ButtonStyleButton {
|
||||
/// each state and "others" means all other states.
|
||||
///
|
||||
/// The `textScaleFactor` is the value of
|
||||
/// `MediaQuery.of(context).textScaleFactor` and the names of the
|
||||
/// `MediaQuery.textScaleFactorOf(context)` and the names of the
|
||||
/// EdgeInsets constructors and `EdgeInsetsGeometry.lerp` have been
|
||||
/// abbreviated for readability.
|
||||
///
|
||||
@ -382,7 +382,7 @@ EdgeInsetsGeometry _scaledPadding(BuildContext context) {
|
||||
const EdgeInsets.all(8),
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
|
||||
MediaQuery.textScaleFactorOf(context),
|
||||
);
|
||||
}
|
||||
|
||||
@ -495,7 +495,7 @@ class _TextButtonWithIcon extends TextButton {
|
||||
const EdgeInsets.all(8),
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
|
||||
MediaQuery.textScaleFactorOf(context),
|
||||
);
|
||||
return super.defaultStyleOf(context).copyWith(
|
||||
padding: MaterialStatePropertyAll<EdgeInsetsGeometry>(scaledPadding),
|
||||
@ -514,7 +514,7 @@ class _TextButtonWithIconChild extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double scale = MediaQuery.maybeOf(context)?.textScaleFactor ?? 1;
|
||||
final double scale = MediaQuery.textScaleFactorOf(context);
|
||||
final double gap = scale <= 1 ? 8 : lerpDouble(8, 4, math.min(scale - 1, 1))!;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -967,7 +967,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
|
||||
}
|
||||
|
||||
bool get _canRequestFocus {
|
||||
final NavigationMode mode = MediaQuery.maybeOf(context)?.navigationMode ?? NavigationMode.traditional;
|
||||
final NavigationMode mode = MediaQuery.maybeNavigationModeOf(context) ?? NavigationMode.traditional;
|
||||
switch (mode) {
|
||||
case NavigationMode.traditional:
|
||||
return _isEnabled;
|
||||
@ -1215,7 +1215,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
|
||||
cursorColor = widget.cursorColor ?? selectionStyle.cursorColor ?? cupertinoTheme.primaryColor;
|
||||
selectionColor = selectionStyle.selectionColor ?? cupertinoTheme.primaryColor.withOpacity(0.40);
|
||||
cursorRadius ??= const Radius.circular(2.0);
|
||||
cursorOffset = Offset(iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0);
|
||||
cursorOffset = Offset(iOSHorizontalOffset / MediaQuery.devicePixelRatioOf(context), 0);
|
||||
autocorrectionTextRectColor = selectionColor;
|
||||
break;
|
||||
|
||||
@ -1228,7 +1228,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
|
||||
cursorColor = widget.cursorColor ?? selectionStyle.cursorColor ?? cupertinoTheme.primaryColor;
|
||||
selectionColor = selectionStyle.selectionColor ?? cupertinoTheme.primaryColor.withOpacity(0.40);
|
||||
cursorRadius ??= const Radius.circular(2.0);
|
||||
cursorOffset = Offset(iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0);
|
||||
cursorOffset = Offset(iOSHorizontalOffset / MediaQuery.devicePixelRatioOf(context), 0);
|
||||
handleDidGainAccessibilityFocus = () {
|
||||
// Automatically activate the TextField when it receives accessibility focus.
|
||||
if (!_effectiveFocusNode.hasFocus && _effectiveFocusNode.canRequestFocus) {
|
||||
|
@ -99,7 +99,7 @@ class TextSelectionToolbar extends StatelessWidget {
|
||||
final Offset anchorBelowPadded =
|
||||
anchorBelow + const Offset(0.0, _kToolbarContentDistanceBelow);
|
||||
|
||||
final double paddingAbove = MediaQuery.of(context).padding.top
|
||||
final double paddingAbove = MediaQuery.paddingOf(context).top
|
||||
+ _kToolbarScreenPadding;
|
||||
final double availableHeight = anchorAbovePadded.dy - _kToolbarContentDistance - paddingAbove;
|
||||
final bool fitsAbove = _kToolbarHeight <= availableHeight;
|
||||
|
@ -108,7 +108,7 @@ class TimeOfDay {
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
return localizations.formatTimeOfDay(
|
||||
this,
|
||||
alwaysUse24HourFormat: MediaQuery.of(context).alwaysUse24HourFormat,
|
||||
alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ class _TimePickerHeader extends StatelessWidget {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
final TimeOfDayFormat timeOfDayFormat = MaterialLocalizations.of(context).timeOfDayFormat(
|
||||
alwaysUse24HourFormat: MediaQuery.of(context).alwaysUse24HourFormat,
|
||||
alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context),
|
||||
);
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
final String timePickerDialHelpText = themeData.useMaterial3
|
||||
@ -339,7 +339,7 @@ class _HourControl extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final bool alwaysUse24HourFormat = MediaQuery.of(context).alwaysUse24HourFormat;
|
||||
final bool alwaysUse24HourFormat = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
final String formattedHour = localizations.formatHour(
|
||||
fragmentContext.selectedTime,
|
||||
@ -581,7 +581,7 @@ class _DayPeriodControl extends StatelessWidget {
|
||||
side: borderSide,
|
||||
);
|
||||
|
||||
final double buttonTextScaleFactor = math.min(MediaQuery.of(context).textScaleFactor, 2.0);
|
||||
final double buttonTextScaleFactor = math.min(MediaQuery.textScaleFactorOf(context), 2.0);
|
||||
|
||||
final Widget amButton = Material(
|
||||
color: MaterialStateProperty.resolveAs(backgroundColor, amStates),
|
||||
@ -990,7 +990,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
|
||||
|
||||
late ThemeData themeData;
|
||||
late MaterialLocalizations localizations;
|
||||
late MediaQueryData media;
|
||||
late bool alwaysUse24HourFormat;
|
||||
_DialPainter? painter;
|
||||
|
||||
@override
|
||||
@ -999,7 +999,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
themeData = Theme.of(context);
|
||||
localizations = MaterialLocalizations.of(context);
|
||||
media = MediaQuery.of(context);
|
||||
alwaysUse24HourFormat = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -1209,7 +1209,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
|
||||
|
||||
_TappableLabel _buildTappableLabel(TextTheme textTheme, Color color, int value, String label, VoidCallback onTap) {
|
||||
final TextStyle style = textTheme.bodyLarge!.copyWith(color: color);
|
||||
final double labelScaleFactor = math.min(MediaQuery.of(context).textScaleFactor, 2.0);
|
||||
final double labelScaleFactor = math.min(MediaQuery.textScaleFactorOf(context), 2.0);
|
||||
return _TappableLabel(
|
||||
value: value,
|
||||
painter: TextPainter(
|
||||
@ -1227,7 +1227,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
|
||||
textTheme,
|
||||
color,
|
||||
timeOfDay.hour,
|
||||
localizations.formatHour(timeOfDay, alwaysUse24HourFormat: media.alwaysUse24HourFormat),
|
||||
localizations.formatHour(timeOfDay, alwaysUse24HourFormat: alwaysUse24HourFormat),
|
||||
() {
|
||||
_selectHour(timeOfDay.hour);
|
||||
},
|
||||
@ -1240,7 +1240,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
|
||||
textTheme,
|
||||
color,
|
||||
timeOfDay.hour,
|
||||
localizations.formatHour(timeOfDay, alwaysUse24HourFormat: media.alwaysUse24HourFormat),
|
||||
localizations.formatHour(timeOfDay, alwaysUse24HourFormat: alwaysUse24HourFormat),
|
||||
() {
|
||||
_selectHour(timeOfDay.hour);
|
||||
},
|
||||
@ -1406,7 +1406,7 @@ class _TimePickerInputState extends State<_TimePickerInput> with RestorationMixi
|
||||
return null;
|
||||
}
|
||||
|
||||
if (MediaQuery.of(context).alwaysUse24HourFormat) {
|
||||
if (MediaQuery.alwaysUse24HourFormatOf(context)) {
|
||||
if (newHour >= 0 && newHour < 24) {
|
||||
return newHour;
|
||||
}
|
||||
@ -1494,8 +1494,7 @@ class _TimePickerInputState extends State<_TimePickerInput> with RestorationMixi
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData media = MediaQuery.of(context);
|
||||
final TimeOfDayFormat timeOfDayFormat = MaterialLocalizations.of(context).timeOfDayFormat(alwaysUse24HourFormat: media.alwaysUse24HourFormat);
|
||||
final TimeOfDayFormat timeOfDayFormat = MaterialLocalizations.of(context).timeOfDayFormat(alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context));
|
||||
final bool use24HourDials = hourFormat(of: timeOfDayFormat) != HourFormat.h;
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final TextStyle hourMinuteStyle = TimePickerTheme.of(context).hourMinuteTextStyle ?? theme.textTheme.displayMedium!;
|
||||
@ -1759,7 +1758,7 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> with Restora
|
||||
}
|
||||
|
||||
String get _formattedValue {
|
||||
final bool alwaysUse24HourFormat = MediaQuery.of(context).alwaysUse24HourFormat;
|
||||
final bool alwaysUse24HourFormat = MediaQuery.alwaysUse24HourFormatOf(context);
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
return !widget.isHour ? localizations.formatMinute(widget.selectedTime) : localizations.formatHour(
|
||||
widget.selectedTime,
|
||||
@ -1805,7 +1804,7 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> with Restora
|
||||
//
|
||||
// TODO(rami-a): Once https://github.com/flutter/flutter/issues/67571 is
|
||||
// resolved, remove the window check for semantics being enabled on web.
|
||||
final String? hintText = MediaQuery.of(context).accessibleNavigation || WidgetsBinding.instance.window.semanticsEnabled
|
||||
final String? hintText = MediaQuery.accessibleNavigationOf(context) || WidgetsBinding.instance.window.semanticsEnabled
|
||||
? widget.semanticHintText
|
||||
: (focusNode.hasFocus ? null : _formattedValue);
|
||||
inputDecoration = inputDecoration.copyWith(
|
||||
@ -2146,11 +2145,10 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
|
||||
return;
|
||||
}
|
||||
|
||||
final MediaQueryData media = MediaQuery.of(context);
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
_announceToAccessibility(
|
||||
context,
|
||||
localizations.formatTimeOfDay(widget.initialTime, alwaysUse24HourFormat: media.alwaysUse24HourFormat),
|
||||
localizations.formatTimeOfDay(widget.initialTime, alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context)),
|
||||
);
|
||||
_announcedInitialTime.value = true;
|
||||
}
|
||||
@ -2195,12 +2193,12 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
|
||||
}
|
||||
|
||||
Size _dialogSize(BuildContext context) {
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
final ThemeData theme = Theme.of(context);
|
||||
// Constrain the textScaleFactor to prevent layout issues. Since only some
|
||||
// parts of the time picker scale up with textScaleFactor, we cap the factor
|
||||
// to 1.1 as that provides enough space to reasonably fit all the content.
|
||||
final double textScaleFactor = math.min(MediaQuery.of(context).textScaleFactor, 1.1);
|
||||
final double textScaleFactor = math.min(MediaQuery.textScaleFactorOf(context), 1.1);
|
||||
|
||||
final double timePickerWidth;
|
||||
final double timePickerHeight;
|
||||
@ -2234,12 +2232,11 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData media = MediaQuery.of(context);
|
||||
final TimeOfDayFormat timeOfDayFormat = localizations.timeOfDayFormat(alwaysUse24HourFormat: media.alwaysUse24HourFormat);
|
||||
final TimeOfDayFormat timeOfDayFormat = localizations.timeOfDayFormat(alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context));
|
||||
final bool use24HourDials = hourFormat(of: timeOfDayFormat) != HourFormat.h;
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final ShapeBorder shape = TimePickerTheme.of(context).shape ?? _kDefaultShape;
|
||||
final Orientation orientation = media.orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
|
||||
final Widget actions = Row(
|
||||
children: <Widget>[
|
||||
|
@ -884,7 +884,7 @@ class _TooltipOverlay extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
return Positioned.fill(
|
||||
bottom: MediaQuery.maybeOf(context)?.viewInsets.bottom ?? 0.0,
|
||||
bottom: MediaQuery.maybeViewInsetsOf(context)?.bottom ?? 0.0,
|
||||
child: CustomSingleChildLayout(
|
||||
delegate: _TooltipPositionDelegate(
|
||||
target: target,
|
||||
|
@ -1230,7 +1230,7 @@ class _FocusableActionDetectorState extends State<FocusableActionDetector> {
|
||||
}
|
||||
|
||||
bool canRequestFocus(FocusableActionDetector target) {
|
||||
final NavigationMode mode = MediaQuery.maybeOf(context)?.navigationMode ?? NavigationMode.traditional;
|
||||
final NavigationMode mode = MediaQuery.maybeNavigationModeOf(context) ?? NavigationMode.traditional;
|
||||
switch (mode) {
|
||||
case NavigationMode.traditional:
|
||||
return target.enabled;
|
||||
@ -1271,7 +1271,7 @@ class _FocusableActionDetectorState extends State<FocusableActionDetector> {
|
||||
}
|
||||
|
||||
bool get _canRequestFocus {
|
||||
final NavigationMode mode = MediaQuery.maybeOf(context)?.navigationMode ?? NavigationMode.traditional;
|
||||
final NavigationMode mode = MediaQuery.maybeNavigationModeOf(context) ?? NavigationMode.traditional;
|
||||
switch (mode) {
|
||||
case NavigationMode.traditional:
|
||||
return widget.enabled;
|
||||
|
@ -447,7 +447,7 @@ class _DraggableState<T extends Object> extends State<Draggable<T>> {
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
_recognizer!.gestureSettings = MediaQuery.maybeOf(context)?.gestureSettings;
|
||||
_recognizer!.gestureSettings = MediaQuery.maybeGestureSettingsOf(context);
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
|
@ -2409,7 +2409,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
|
||||
}
|
||||
|
||||
// Hide the text selection toolbar on mobile when orientation changes.
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
if (_lastOrientation == null) {
|
||||
_lastOrientation = orientation;
|
||||
return;
|
||||
@ -3583,7 +3583,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
|
||||
@override
|
||||
TextEditingValue get textEditingValue => _value;
|
||||
|
||||
double get _devicePixelRatio => MediaQuery.of(context).devicePixelRatio;
|
||||
double get _devicePixelRatio => MediaQuery.devicePixelRatioOf(context);
|
||||
|
||||
@override
|
||||
void userUpdateTextEditingValue(TextEditingValue value, SelectionChangedCause? cause) {
|
||||
|
@ -1017,7 +1017,7 @@ class GestureDetector extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Map<Type, GestureRecognizerFactory> gestures = <Type, GestureRecognizerFactory>{};
|
||||
final DeviceGestureSettings? gestureSettings = MediaQuery.maybeOf(context)?.gestureSettings;
|
||||
final DeviceGestureSettings? gestureSettings = MediaQuery.maybeGestureSettingsOf(context);
|
||||
|
||||
if (onTapDown != null ||
|
||||
onTapUp != null ||
|
||||
|
@ -53,7 +53,7 @@ export 'package:flutter/painting.dart' show
|
||||
ImageConfiguration createLocalImageConfiguration(BuildContext context, { Size? size }) {
|
||||
return ImageConfiguration(
|
||||
bundle: DefaultAssetBundle.of(context),
|
||||
devicePixelRatio: MediaQuery.maybeOf(context)?.devicePixelRatio ?? 1.0,
|
||||
devicePixelRatio: MediaQuery.maybeDevicePixelRatioOf(context) ?? 1.0,
|
||||
locale: Localizations.maybeLocaleOf(context),
|
||||
textDirection: Directionality.maybeOf(context),
|
||||
size: size,
|
||||
@ -1106,7 +1106,7 @@ class _ImageState extends State<Image> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
void _updateInvertColors() {
|
||||
_invertColors = MediaQuery.maybeOf(context)?.invertColors
|
||||
_invertColors = MediaQuery.maybeInvertColorsOf(context)
|
||||
?? SemanticsBinding.instance.accessibilityFeatures.invertColors;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import 'basic.dart';
|
||||
import 'binding.dart';
|
||||
import 'debug.dart';
|
||||
import 'framework.dart';
|
||||
import 'inherited_model.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// late BuildContext context;
|
||||
@ -25,6 +26,52 @@ enum Orientation {
|
||||
landscape
|
||||
}
|
||||
|
||||
/// Specifies a part of MediaQueryData to depend on.
|
||||
///
|
||||
/// [MediaQuery] contains a large number of related properties. Widgets frequently
|
||||
/// depend on only a few of these attributes. For example, a widget that needs to
|
||||
/// rebuild when the [MediaQueryData.textScaleFactor] changes does not need to
|
||||
/// be notified when the [MediaQueryData.size] changes. Specifying an aspect avoids
|
||||
/// unnecessary rebuilds.
|
||||
enum _MediaQueryAspect {
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.size].
|
||||
size,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.orientation].
|
||||
orientation,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.devicePixelRatio].
|
||||
devicePixelRatio,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.textScaleFactor].
|
||||
textScaleFactor,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.platformBrightness].
|
||||
platformBrightness,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.padding].
|
||||
padding,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.viewInsets].
|
||||
viewInsets,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.systemGestureInsets].
|
||||
systemGestureInsets,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.viewPadding].
|
||||
viewPadding,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.alwaysUse24HourFormat].
|
||||
alwaysUse24HourFormat,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.accessibleNavigation].
|
||||
accessibleNavigation,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.invertColors].
|
||||
invertColors,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.highContrast].
|
||||
highContrast,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.disableAnimations].
|
||||
disableAnimations,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.boldText].
|
||||
boldText,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.navigationMode].
|
||||
navigationMode,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.gestureSettings].
|
||||
gestureSettings,
|
||||
/// Specifies the aspect corresponding to [MediaQueryData.displayFeatures].
|
||||
displayFeatures,
|
||||
}
|
||||
|
||||
/// Information about a piece of media (e.g., a window).
|
||||
///
|
||||
/// For example, the [MediaQueryData.size] property contains the width and
|
||||
@ -178,6 +225,8 @@ class MediaQueryData {
|
||||
/// See also:
|
||||
///
|
||||
/// * [FlutterView.physicalSize], which returns the size in physical pixels.
|
||||
/// * [MediaQuery.sizeOf], a method to find and depend on the size defined
|
||||
/// for a [BuildContext].
|
||||
final Size size;
|
||||
|
||||
/// The number of device pixels for each logical pixel. This number might not
|
||||
@ -192,7 +241,7 @@ class MediaQueryData {
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [MediaQuery.textScaleFactorOf], a convenience method which returns the
|
||||
/// * [MediaQuery.textScaleFactorOf], a method to find and depend on the
|
||||
/// textScaleFactor defined for a [BuildContext].
|
||||
final double textScaleFactor;
|
||||
|
||||
@ -203,6 +252,11 @@ class MediaQueryData {
|
||||
///
|
||||
/// Not all platforms necessarily support a concept of brightness mode. Those
|
||||
/// platforms will report [Brightness.light] in this property.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [MediaQuery.platformBrightnessOf], a method to find and depend on the
|
||||
/// platformBrightness defined for a [BuildContext].
|
||||
final Brightness platformBrightness;
|
||||
|
||||
/// The parts of the display that are completely obscured by system UI,
|
||||
@ -690,7 +744,7 @@ class MediaQueryData {
|
||||
/// * [WidgetsApp] and [MaterialApp], which introduce a [MediaQuery] and keep
|
||||
/// it up to date with the current screen metrics as they change.
|
||||
/// * [MediaQueryData], the data structure that represents the metrics.
|
||||
class MediaQuery extends InheritedWidget {
|
||||
class MediaQuery extends InheritedModel<_MediaQueryAspect> {
|
||||
/// Creates a widget that provides [MediaQueryData] to its descendants.
|
||||
///
|
||||
/// The [data] and [child] arguments must not be null.
|
||||
@ -873,6 +927,11 @@ class MediaQuery extends InheritedWidget {
|
||||
/// examples). When that information changes, your widget will be scheduled to
|
||||
/// be rebuilt, keeping your widget up-to-date.
|
||||
///
|
||||
/// If the widget only requires a subset of properties of the [MediaQueryData]
|
||||
/// object, it is preferred to use the specific methods (for example:
|
||||
/// [MediaQuery.sizeOf] and [MediaQuery.paddingOf]), as those methods will not
|
||||
/// cause a widget to rebuild when unrelated properties are updated.
|
||||
///
|
||||
/// Typical usage is as follows:
|
||||
///
|
||||
/// ```dart
|
||||
@ -889,8 +948,12 @@ class MediaQuery extends InheritedWidget {
|
||||
/// [MediaQuery] ancestor, it returns null instead.
|
||||
static MediaQueryData of(BuildContext context) {
|
||||
assert(context != null);
|
||||
return _of(context);
|
||||
}
|
||||
|
||||
static MediaQueryData _of(BuildContext context, [_MediaQueryAspect? aspect]) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
return context.dependOnInheritedWidgetOfExactType<MediaQuery>()!.data;
|
||||
return InheritedModel.inheritFrom<MediaQuery>(context, aspect: aspect)!.data;
|
||||
}
|
||||
|
||||
/// The data from the closest instance of this class that encloses the given
|
||||
@ -907,6 +970,11 @@ class MediaQuery extends InheritedWidget {
|
||||
/// examples). When that information changes, your widget will be scheduled to
|
||||
/// be rebuilt, keeping your widget up-to-date.
|
||||
///
|
||||
/// If the widget only requires a subset of properties of the [MediaQueryData]
|
||||
/// object, it is preferred to use the specific methods (for example:
|
||||
/// [MediaQuery.maybeSizeOf] and [MediaQuery.maybePaddingOf]), as those methods
|
||||
/// will not cause a widget to rebuild when unrelated properties are updated.
|
||||
///
|
||||
/// Typical usage is as follows:
|
||||
///
|
||||
/// ```dart
|
||||
@ -922,23 +990,182 @@ class MediaQuery extends InheritedWidget {
|
||||
/// instead of returning null.
|
||||
static MediaQueryData? maybeOf(BuildContext context) {
|
||||
assert(context != null);
|
||||
return context.dependOnInheritedWidgetOfExactType<MediaQuery>()?.data;
|
||||
return _maybeOf(context);
|
||||
}
|
||||
|
||||
/// Returns textScaleFactor for the nearest MediaQuery ancestor or 1.0, if
|
||||
/// no such ancestor exists.
|
||||
static double textScaleFactorOf(BuildContext context) {
|
||||
return MediaQuery.maybeOf(context)?.textScaleFactor ?? 1.0;
|
||||
static MediaQueryData? _maybeOf(BuildContext context, [_MediaQueryAspect? aspect]) {
|
||||
return InheritedModel.inheritFrom<MediaQuery>(context, aspect: aspect)?.data;
|
||||
}
|
||||
|
||||
/// Returns size for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.size] property of the ancestor [MediaQuery] changes.
|
||||
static Size sizeOf(BuildContext context) => _of(context, _MediaQueryAspect.size).size;
|
||||
|
||||
/// Returns size for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.size] property of the ancestor [MediaQuery] changes.
|
||||
static Size? maybeSizeOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.size)?.size;
|
||||
|
||||
/// Returns orientation for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.orientation] property of the ancestor [MediaQuery] changes.
|
||||
static Orientation orientationOf(BuildContext context) => _of(context, _MediaQueryAspect.orientation).orientation;
|
||||
|
||||
/// Returns orientation for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.orientation] property of the ancestor [MediaQuery] changes.
|
||||
static Orientation? maybeOrientationOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.orientation)?.orientation;
|
||||
|
||||
/// Returns devicePixelRatio for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.devicePixelRatio] property of the ancestor [MediaQuery] changes.
|
||||
static double devicePixelRatioOf(BuildContext context) => _of(context, _MediaQueryAspect.devicePixelRatio).devicePixelRatio;
|
||||
|
||||
/// Returns devicePixelRatio for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.devicePixelRatio] property of the ancestor [MediaQuery] changes.
|
||||
static double? maybeDevicePixelRatioOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.devicePixelRatio)?.devicePixelRatio;
|
||||
|
||||
/// Returns textScaleFactor for the nearest MediaQuery ancestor or
|
||||
/// 1.0, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.textScaleFactor] property of the ancestor [MediaQuery] changes.
|
||||
static double textScaleFactorOf(BuildContext context) => maybeTextScaleFactorOf(context) ?? 1.0;
|
||||
|
||||
/// Returns textScaleFactor for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.textScaleFactor] property of the ancestor [MediaQuery] changes.
|
||||
static double? maybeTextScaleFactorOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.textScaleFactor)?.textScaleFactor;
|
||||
|
||||
/// Returns platformBrightness for the nearest MediaQuery ancestor or
|
||||
/// [Brightness.light], if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// any property of the ancestor [MediaQuery] changes.
|
||||
static Brightness platformBrightnessOf(BuildContext context) {
|
||||
return MediaQuery.maybeOf(context)?.platformBrightness ?? Brightness.light;
|
||||
}
|
||||
/// the [MediaQueryData.platformBrightness] property of the ancestor
|
||||
/// [MediaQuery] changes.
|
||||
static Brightness platformBrightnessOf(BuildContext context) => maybePlatformBrightnessOf(context) ?? Brightness.light;
|
||||
|
||||
/// Returns platformBrightness for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.platformBrightness] property of the ancestor
|
||||
/// [MediaQuery] changes.
|
||||
static Brightness? maybePlatformBrightnessOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.platformBrightness)?.platformBrightness;
|
||||
|
||||
/// Returns padding for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.padding] property of the ancestor [MediaQuery] changes.
|
||||
static EdgeInsets paddingOf(BuildContext context) => _of(context, _MediaQueryAspect.padding).padding;
|
||||
|
||||
/// Returns viewInsets for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.viewInsets] property of the ancestor [MediaQuery] changes.
|
||||
static EdgeInsets? maybePaddingOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.padding)?.padding;
|
||||
|
||||
/// Returns viewInsets for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.viewInsets] property of the ancestor [MediaQuery] changes.
|
||||
static EdgeInsets viewInsetsOf(BuildContext context) => _of(context, _MediaQueryAspect.viewInsets).viewInsets;
|
||||
|
||||
/// Returns viewInsets for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.viewInsets] property of the ancestor [MediaQuery] changes.
|
||||
static EdgeInsets? maybeViewInsetsOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.viewInsets)?.viewInsets;
|
||||
|
||||
/// Returns systemGestureInsets for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.systemGestureInsets] property of the ancestor [MediaQuery] changes.
|
||||
static EdgeInsets systemGestureInsetsOf(BuildContext context) => _of(context, _MediaQueryAspect.systemGestureInsets).systemGestureInsets;
|
||||
|
||||
/// Returns systemGestureInsets for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.systemGestureInsets] property of the ancestor [MediaQuery] changes.
|
||||
static EdgeInsets? maybeSystemGestureInsetsOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.systemGestureInsets)?.systemGestureInsets;
|
||||
|
||||
/// Returns viewPadding for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.viewPadding] property of the ancestor [MediaQuery] changes.
|
||||
static EdgeInsets viewPaddingOf(BuildContext context) => _of(context, _MediaQueryAspect.viewPadding).viewPadding;
|
||||
|
||||
/// Returns viewPadding for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.viewPadding] property of the ancestor [MediaQuery] changes.
|
||||
static EdgeInsets? maybeViewPaddingOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.viewPadding)?.viewPadding;
|
||||
|
||||
/// Returns alwaysUse for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.devicePixelRatio] property of the ancestor [MediaQuery] changes.
|
||||
static bool alwaysUse24HourFormatOf(BuildContext context) => _of(context, _MediaQueryAspect.alwaysUse24HourFormat).alwaysUse24HourFormat;
|
||||
|
||||
/// Returns alwaysUse24HourFormat for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.alwaysUse24HourFormat] property of the ancestor [MediaQuery] changes.
|
||||
static bool? maybeAlwaysUse24HourFormatOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.alwaysUse24HourFormat)?.alwaysUse24HourFormat;
|
||||
|
||||
/// Returns accessibleNavigationOf for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.accessibleNavigation] property of the ancestor [MediaQuery] changes.
|
||||
static bool accessibleNavigationOf(BuildContext context) => _of(context, _MediaQueryAspect.accessibleNavigation).accessibleNavigation;
|
||||
|
||||
/// Returns accessibleNavigation for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.accessibleNavigation] property of the ancestor [MediaQuery] changes.
|
||||
static bool? maybeAccessibleNavigationOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.accessibleNavigation)?.accessibleNavigation;
|
||||
|
||||
/// Returns invertColorsOf for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.invertColors] property of the ancestor [MediaQuery] changes.
|
||||
static bool invertColorsOf(BuildContext context) => _of(context, _MediaQueryAspect.invertColors).invertColors;
|
||||
|
||||
/// Returns invertColors for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.invertColors] property of the ancestor [MediaQuery] changes.
|
||||
static bool? maybeInvertColorsOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.invertColors)?.invertColors;
|
||||
|
||||
/// Returns highContrast for the nearest MediaQuery ancestor or false, if no
|
||||
/// such ancestor exists.
|
||||
@ -947,15 +1174,102 @@ class MediaQuery extends InheritedWidget {
|
||||
///
|
||||
/// * [MediaQueryData.highContrast], which indicates the platform's
|
||||
/// desire to increase contrast.
|
||||
static bool highContrastOf(BuildContext context) {
|
||||
return MediaQuery.maybeOf(context)?.highContrast ?? false;
|
||||
}
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.highContrast] property of the ancestor [MediaQuery] changes.
|
||||
static bool highContrastOf(BuildContext context) => maybeHighContrastOf(context) ?? false;
|
||||
|
||||
/// Returns highContrast for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.highContrast] property of the ancestor [MediaQuery] changes.
|
||||
static bool? maybeHighContrastOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.highContrast)?.highContrast;
|
||||
|
||||
/// Returns disableAnimations for the nearest MediaQuery ancestor or
|
||||
/// [Brightness.light], if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.disableAnimations] property of the ancestor
|
||||
/// [MediaQuery] changes.
|
||||
static bool disableAnimationsOf(BuildContext context) => _of(context, _MediaQueryAspect.disableAnimations).disableAnimations;
|
||||
|
||||
/// Returns disableAnimations for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.disableAnimations] property of the ancestor [MediaQuery] changes.
|
||||
static bool? maybeDisableAnimationsOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.disableAnimations)?.disableAnimations;
|
||||
|
||||
|
||||
/// Returns the boldText accessibility setting for the nearest MediaQuery
|
||||
/// ancestor, or false if no such ancestor exists.
|
||||
static bool boldTextOverride(BuildContext context) {
|
||||
return MediaQuery.maybeOf(context)?.boldText ?? false;
|
||||
}
|
||||
/// ancestor or false, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.boldText] property of the ancestor [MediaQuery] changes.
|
||||
static bool boldTextOf(BuildContext context) => maybeBoldTextOf(context) ?? false;
|
||||
|
||||
/// Returns the boldText accessibility setting for the nearest MediaQuery
|
||||
/// ancestor or false, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.boldText] property of the ancestor [MediaQuery] changes.
|
||||
///
|
||||
/// Deprecated in favor of [boldTextOf].
|
||||
@Deprecated(
|
||||
'Migrate to boldTextOf. '
|
||||
'This feature was deprecated after v3.5.0-9.0.pre.'
|
||||
)
|
||||
static bool boldTextOverride(BuildContext context) => boldTextOf(context);
|
||||
|
||||
/// Returns the boldText accessibility setting for the nearest MediaQuery
|
||||
/// ancestor or null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.boldText] property of the ancestor [MediaQuery] changes.
|
||||
static bool? maybeBoldTextOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.boldText)?.boldText;
|
||||
|
||||
/// Returns navigationMode for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.navigationMode] property of the ancestor [MediaQuery] changes.
|
||||
static NavigationMode navigationModeOf(BuildContext context) => _of(context, _MediaQueryAspect.navigationMode).navigationMode;
|
||||
|
||||
/// Returns navigationMode for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.navigationMode] property of the ancestor [MediaQuery] changes.
|
||||
static NavigationMode? maybeNavigationModeOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.navigationMode)?.navigationMode;
|
||||
|
||||
/// Returns gestureSettings for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.gestureSettings] property of the ancestor [MediaQuery] changes.
|
||||
static DeviceGestureSettings gestureSettingsOf(BuildContext context) => _of(context, _MediaQueryAspect.gestureSettings).gestureSettings;
|
||||
|
||||
/// Returns gestureSettings for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.gestureSettings] property of the ancestor [MediaQuery] changes.
|
||||
static DeviceGestureSettings? maybeGestureSettingsOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.gestureSettings)?.gestureSettings;
|
||||
|
||||
/// Returns displayFeatures for the nearest MediaQuery ancestor or
|
||||
/// throws an exception, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.displayFeatures] property of the ancestor [MediaQuery] changes.
|
||||
static List<ui.DisplayFeature> displayFeaturesOf(BuildContext context) => _of(context, _MediaQueryAspect.displayFeatures).displayFeatures;
|
||||
|
||||
/// Returns displayFeatures for the nearest MediaQuery ancestor or
|
||||
/// null, if no such ancestor exists.
|
||||
///
|
||||
/// Use of this method will cause the given [context] to rebuild any time that
|
||||
/// the [MediaQueryData.displayFeatures] property of the ancestor [MediaQuery] changes.
|
||||
static List<ui.DisplayFeature>? maybeDisplayFeaturesOf(BuildContext context) => _maybeOf(context, _MediaQueryAspect.displayFeatures)?.displayFeatures;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(MediaQuery oldWidget) => data != oldWidget.data;
|
||||
@ -965,6 +1279,27 @@ class MediaQuery extends InheritedWidget {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(DiagnosticsProperty<MediaQueryData>('data', data, showName: false));
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotifyDependent(MediaQuery oldWidget, Set<Object> dependencies) {
|
||||
return (data.size != oldWidget.data.size && dependencies.contains(_MediaQueryAspect.size))
|
||||
|| (data.orientation != oldWidget.data.orientation && dependencies.contains(_MediaQueryAspect.orientation))
|
||||
|| (data.devicePixelRatio != oldWidget.data.devicePixelRatio && dependencies.contains(_MediaQueryAspect.devicePixelRatio))
|
||||
|| (data.textScaleFactor != oldWidget.data.textScaleFactor && dependencies.contains(_MediaQueryAspect.textScaleFactor))
|
||||
|| (data.platformBrightness != oldWidget.data.platformBrightness && dependencies.contains(_MediaQueryAspect.platformBrightness))
|
||||
|| (data.viewInsets != oldWidget.data.viewInsets && dependencies.contains(_MediaQueryAspect.viewInsets))
|
||||
|| (data.systemGestureInsets != oldWidget.data.systemGestureInsets && dependencies.contains(_MediaQueryAspect.systemGestureInsets))
|
||||
|| (data.viewPadding != oldWidget.data.viewPadding && dependencies.contains(_MediaQueryAspect.viewPadding))
|
||||
|| (data.alwaysUse24HourFormat != oldWidget.data.alwaysUse24HourFormat && dependencies.contains(_MediaQueryAspect.alwaysUse24HourFormat))
|
||||
|| (data.accessibleNavigation != oldWidget.data.accessibleNavigation && dependencies.contains(_MediaQueryAspect.accessibleNavigation))
|
||||
|| (data.invertColors != oldWidget.data.invertColors && dependencies.contains(_MediaQueryAspect.invertColors))
|
||||
|| (data.highContrast != oldWidget.data.highContrast && dependencies.contains(_MediaQueryAspect.highContrast))
|
||||
|| (data.disableAnimations != oldWidget.data.disableAnimations && dependencies.contains(_MediaQueryAspect.disableAnimations))
|
||||
|| (data.boldText != oldWidget.data.boldText && dependencies.contains(_MediaQueryAspect.boldText))
|
||||
|| (data.navigationMode != oldWidget.data.navigationMode && dependencies.contains(_MediaQueryAspect.navigationMode))
|
||||
|| (data.gestureSettings != oldWidget.data.gestureSettings && dependencies.contains(_MediaQueryAspect.gestureSettings))
|
||||
|| (data.displayFeatures != oldWidget.data.displayFeatures && dependencies.contains(_MediaQueryAspect.displayFeatures));
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes the navigation mode to be set by a [MediaQuery] widget.
|
||||
@ -972,7 +1307,7 @@ class MediaQuery extends InheritedWidget {
|
||||
/// The different modes indicate the type of navigation to be used in a widget
|
||||
/// subtree for those widgets sensitive to it.
|
||||
///
|
||||
/// Use `MediaQuery.of(context).navigationMode` to determine the navigation mode
|
||||
/// Use `MediaQuery.navigationModeOf(context)` to determine the navigation mode
|
||||
/// in effect for the given context. Use a [MediaQuery] widget to set the
|
||||
/// navigation mode for its descendant widgets.
|
||||
enum NavigationMode {
|
||||
|
@ -774,7 +774,7 @@ class _StretchingOverscrollIndicatorState extends State<StretchingOverscrollIndi
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Size size = MediaQuery.of(context).size;
|
||||
final Size size = MediaQuery.sizeOf(context);
|
||||
double mainAxisSize;
|
||||
return NotificationListener<ScrollNotification>(
|
||||
onNotification: _handleScrollNotification,
|
||||
|
@ -1163,7 +1163,7 @@ class ReorderableDragStartListener extends StatelessWidget {
|
||||
}
|
||||
|
||||
void _startDragging(BuildContext context, PointerDownEvent event) {
|
||||
final DeviceGestureSettings? gestureSettings = MediaQuery.maybeOf(context)?.gestureSettings;
|
||||
final DeviceGestureSettings? gestureSettings = MediaQuery.maybeGestureSettingsOf(context);
|
||||
final SliverReorderableListState? list = SliverReorderableList.maybeOf(context);
|
||||
list?.startItemDragReorder(
|
||||
index: index,
|
||||
|
@ -93,11 +93,10 @@ class SafeArea extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final MediaQueryData data = MediaQuery.of(context);
|
||||
EdgeInsets padding = data.padding;
|
||||
EdgeInsets padding = MediaQuery.paddingOf(context);
|
||||
// Bottom padding has been consumed - i.e. by the keyboard
|
||||
if (maintainBottomViewPadding) {
|
||||
padding = padding.copyWith(bottom: data.viewPadding.bottom);
|
||||
padding = padding.copyWith(bottom: MediaQuery.viewPaddingOf(context).bottom);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
@ -192,7 +191,7 @@ class SliverSafeArea extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
final EdgeInsets padding = MediaQuery.of(context).padding;
|
||||
final EdgeInsets padding = MediaQuery.paddingOf(context);
|
||||
return SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
left: math.max(left ? padding.left : 0.0, minimum.left),
|
||||
|
@ -461,7 +461,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
|
||||
late ScrollBehavior _configuration;
|
||||
ScrollPhysics? _physics;
|
||||
ScrollController? _fallbackScrollController;
|
||||
MediaQueryData? _mediaQueryData;
|
||||
DeviceGestureSettings? _mediaQueryGestureSettings;
|
||||
|
||||
ScrollController get _effectiveScrollController => widget.controller ?? _fallbackScrollController!;
|
||||
|
||||
@ -516,7 +516,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
_mediaQueryData = MediaQuery.maybeOf(context);
|
||||
_mediaQueryGestureSettings = MediaQuery.maybeGestureSettingsOf(context);
|
||||
_updatePosition();
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
@ -635,7 +635,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
|
||||
..maxFlingVelocity = _physics?.maxFlingVelocity
|
||||
..velocityTrackerBuilder = _configuration.velocityTrackerBuilder(context)
|
||||
..dragStartBehavior = widget.dragStartBehavior
|
||||
..gestureSettings = _mediaQueryData?.gestureSettings;
|
||||
..gestureSettings = _mediaQueryGestureSettings;
|
||||
},
|
||||
),
|
||||
};
|
||||
@ -656,7 +656,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
|
||||
..maxFlingVelocity = _physics?.maxFlingVelocity
|
||||
..velocityTrackerBuilder = _configuration.velocityTrackerBuilder(context)
|
||||
..dragStartBehavior = widget.dragStartBehavior
|
||||
..gestureSettings = _mediaQueryData?.gestureSettings;
|
||||
..gestureSettings = _mediaQueryGestureSettings;
|
||||
},
|
||||
),
|
||||
};
|
||||
|
@ -1675,7 +1675,7 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
|
||||
..textDirection = Directionality.of(context)
|
||||
..thickness = widget.thickness ?? _kScrollbarThickness
|
||||
..radius = widget.radius
|
||||
..padding = widget.padding ?? MediaQuery.of(context).padding
|
||||
..padding = widget.padding ?? MediaQuery.paddingOf(context)
|
||||
..scrollbarOrientation = widget.scrollbarOrientation
|
||||
..mainAxisMargin = widget.mainAxisMargin
|
||||
..shape = widget.shape
|
||||
|
@ -350,7 +350,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
|
||||
}
|
||||
|
||||
// Hide the text selection toolbar on mobile when orientation changes.
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
if (_lastOrientation == null) {
|
||||
_lastOrientation = orientation;
|
||||
return;
|
||||
|
@ -141,7 +141,7 @@ class SnapshotWidget extends SingleChildRenderObjectWidget {
|
||||
return _RenderSnapshotWidget(
|
||||
controller: controller,
|
||||
mode: mode,
|
||||
devicePixelRatio: MediaQuery.of(context).devicePixelRatio,
|
||||
devicePixelRatio: MediaQuery.devicePixelRatioOf(context),
|
||||
painter: painter,
|
||||
autoresize: autoresize,
|
||||
);
|
||||
@ -153,7 +153,7 @@ class SnapshotWidget extends SingleChildRenderObjectWidget {
|
||||
(renderObject as _RenderSnapshotWidget)
|
||||
..controller = controller
|
||||
..mode = mode
|
||||
..devicePixelRatio = MediaQuery.of(context).devicePixelRatio
|
||||
..devicePixelRatio = MediaQuery.devicePixelRatioOf(context)
|
||||
..painter = painter
|
||||
..autoresize = autoresize;
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ class Text extends StatelessWidget {
|
||||
if (style == null || style!.inherit) {
|
||||
effectiveTextStyle = defaultTextStyle.style.merge(style);
|
||||
}
|
||||
if (MediaQuery.boldTextOverride(context)) {
|
||||
if (MediaQuery.boldTextOf(context)) {
|
||||
effectiveTextStyle = effectiveTextStyle!.merge(const TextStyle(fontWeight: FontWeight.bold));
|
||||
}
|
||||
final SelectionRegistrar? registrar = SelectionContainer.maybeOf(context);
|
||||
|
@ -362,7 +362,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
createAppWithButtonThatLaunchesActionSheet(
|
||||
Builder(builder: (BuildContext context) {
|
||||
screenHeight = MediaQuery.of(context).size.height;
|
||||
screenHeight = MediaQuery.sizeOf(context).height;
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0),
|
||||
child: CupertinoActionSheet(
|
||||
|
@ -588,7 +588,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
createAppWithButtonThatLaunchesDialog(
|
||||
dialogBuilder: (BuildContext context) {
|
||||
dividerWidth = 1.0 / MediaQuery.of(context).devicePixelRatio;
|
||||
dividerWidth = 1.0 / MediaQuery.devicePixelRatioOf(context);
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text('The Title'),
|
||||
content: const Text('The message'),
|
||||
@ -633,7 +633,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
createAppWithButtonThatLaunchesDialog(
|
||||
dialogBuilder: (BuildContext context) {
|
||||
dividerThickness = 1.0 / MediaQuery.of(context).devicePixelRatio;
|
||||
dividerThickness = 1.0 / MediaQuery.devicePixelRatioOf(context);
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text('The Title'),
|
||||
content: const Text('The message'),
|
||||
@ -841,7 +841,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
createAppWithButtonThatLaunchesDialog(
|
||||
dialogBuilder: (BuildContext context) {
|
||||
dividerThickness = 1.0 / MediaQuery.of(context).devicePixelRatio;
|
||||
dividerThickness = 1.0 / MediaQuery.devicePixelRatioOf(context);
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text('The Title'),
|
||||
content: const Text('The message'),
|
||||
|
@ -117,14 +117,14 @@ void main() {
|
||||
caretRect: reasonableTextField,
|
||||
// The tap position is far out of the right side of the app.
|
||||
globalGesturePosition:
|
||||
Offset(MediaQuery.of(context).size.width + 100, 0),
|
||||
Offset(MediaQuery.sizeOf(context).width + 100, 0),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Should be less than the right edge, since we have padding.
|
||||
expect(getMagnifierPosition(tester).dx,
|
||||
lessThan(MediaQuery.of(context).size.width));
|
||||
lessThan(MediaQuery.sizeOf(context).width));
|
||||
});
|
||||
|
||||
testWidgets('should have some vertical drag', (WidgetTester tester) async {
|
||||
@ -150,7 +150,7 @@ void main() {
|
||||
caretRect: reasonableTextField,
|
||||
// The tap position is dragBelow units below the text field.
|
||||
globalGesturePosition: Offset(
|
||||
MediaQuery.of(context).size.width / 2,
|
||||
MediaQuery.sizeOf(context).width / 2,
|
||||
dragPositionBelowTextField),
|
||||
),
|
||||
),
|
||||
@ -184,7 +184,7 @@ void main() {
|
||||
caretRect: reasonableTextField,
|
||||
// The tap position is dragBelow units below the text field.
|
||||
globalGesturePosition: Offset(
|
||||
MediaQuery.of(context).size.width / 2, reasonableTextField.top),
|
||||
MediaQuery.sizeOf(context).width / 2, reasonableTextField.top),
|
||||
),
|
||||
);
|
||||
|
||||
@ -223,7 +223,7 @@ void main() {
|
||||
fieldBounds: reasonableTextField,
|
||||
caretRect: reasonableTextField,
|
||||
// The tap position is dragBelow units below the text field.
|
||||
globalGesturePosition: Offset(MediaQuery.of(context).size.width / 2, reasonableTextField.top),
|
||||
globalGesturePosition: Offset(MediaQuery.sizeOf(context).width / 2, reasonableTextField.top),
|
||||
),
|
||||
);
|
||||
|
||||
@ -247,7 +247,7 @@ void main() {
|
||||
currentLineBoundaries: reasonableTextField,
|
||||
fieldBounds: reasonableTextField,
|
||||
caretRect: reasonableTextField,
|
||||
globalGesturePosition: Offset(MediaQuery.of(context).size.width / 2,
|
||||
globalGesturePosition: Offset(MediaQuery.sizeOf(context).width / 2,
|
||||
reasonableTextField.top));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
|
@ -501,7 +501,7 @@ void main() {
|
||||
items: List<BottomNavigationBarItem>.generate(2, tabGenerator),
|
||||
),
|
||||
tabBuilder: (BuildContext context, int index) {
|
||||
contentPadding = MediaQuery.of(context).padding;
|
||||
contentPadding = MediaQuery.paddingOf(context);
|
||||
return const Placeholder();
|
||||
},
|
||||
),
|
||||
|
@ -26,10 +26,10 @@ class _CustomCupertinoTextSelectionControls extends CupertinoTextSelectionContro
|
||||
ValueNotifier<ClipboardStatus>? clipboardStatus,
|
||||
Offset? lastSecondaryTapDownPosition,
|
||||
) {
|
||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||
final EdgeInsets mediaQueryPadding = MediaQuery.paddingOf(context);
|
||||
final double anchorX = (selectionMidpoint.dx + globalEditableRegion.left).clamp(
|
||||
_kArrowScreenPadding + mediaQuery.padding.left,
|
||||
mediaQuery.size.width - mediaQuery.padding.right - _kArrowScreenPadding,
|
||||
_kArrowScreenPadding + mediaQueryPadding.left,
|
||||
MediaQuery.sizeOf(context).width - mediaQueryPadding.right - _kArrowScreenPadding,
|
||||
);
|
||||
final Offset anchorAbove = Offset(
|
||||
anchorX,
|
||||
|
@ -475,7 +475,7 @@ void main() {
|
||||
double? textScaleFactor;
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Builder(builder:(BuildContext context) {
|
||||
textScaleFactor = MediaQuery.of(context).textScaleFactor;
|
||||
textScaleFactor = MediaQuery.textScaleFactorOf(context);
|
||||
return Container();
|
||||
}),
|
||||
));
|
||||
|
@ -438,7 +438,7 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
width = MediaQuery.of(context).size.width;
|
||||
width = MediaQuery.sizeOf(context).width;
|
||||
return CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
SliverAppBar(
|
||||
|
@ -2443,7 +2443,7 @@ void main() {
|
||||
value: 1,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
mediaQueryPadding = MediaQuery.of(context).padding;
|
||||
mediaQueryPadding = MediaQuery.paddingOf(context);
|
||||
return Text('-1-' * 500); // A long long text string.
|
||||
},
|
||||
),
|
||||
|
@ -925,7 +925,7 @@ void main() {
|
||||
extendBody: extendBody,
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
mediaQueryBottom = MediaQuery.of(context).padding.bottom;
|
||||
mediaQueryBottom = MediaQuery.paddingOf(context).bottom;
|
||||
return Container(key: bodyKey);
|
||||
},
|
||||
),
|
||||
@ -998,7 +998,7 @@ void main() {
|
||||
),
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
mediaQueryTop = MediaQuery.of(context).padding.top;
|
||||
mediaQueryTop = MediaQuery.paddingOf(context).top;
|
||||
return Container(key: bodyKey);
|
||||
},
|
||||
),
|
||||
@ -1957,7 +1957,7 @@ void main() {
|
||||
MaterialApp(
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
screenWidth = MediaQuery.of(context).size.width;
|
||||
screenWidth = MediaQuery.sizeOf(context).width;
|
||||
return Scaffold(
|
||||
endDrawer: const Drawer(
|
||||
child: Text('Drawer'),
|
||||
|
@ -229,7 +229,7 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
width = MediaQuery.of(context).size.width;
|
||||
width = MediaQuery.sizeOf(context).width;
|
||||
|
||||
return GestureDetector(
|
||||
key: tapTarget,
|
||||
|
@ -502,7 +502,7 @@ void main() {
|
||||
children: <Widget>[
|
||||
const Text('top', textDirection: TextDirection.ltr),
|
||||
Builder(builder: (BuildContext context) {
|
||||
innerMediaQueryPadding = MediaQuery.of(context).padding;
|
||||
innerMediaQueryPadding = MediaQuery.paddingOf(context);
|
||||
return Container();
|
||||
}),
|
||||
],
|
||||
|
@ -5,7 +5,7 @@
|
||||
import 'dart:ui' show Brightness, DisplayFeature, DisplayFeatureState, DisplayFeatureType, GestureSettings, ViewConfiguration;
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
@ -686,21 +686,21 @@ void main() {
|
||||
expect(insideHighContrast, true);
|
||||
});
|
||||
|
||||
testWidgets('MediaQuery.boldTextOverride', (WidgetTester tester) async {
|
||||
testWidgets('MediaQuery.boldTextOf', (WidgetTester tester) async {
|
||||
late bool outsideBoldTextOverride;
|
||||
late bool insideBoldTextOverride;
|
||||
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (BuildContext context) {
|
||||
outsideBoldTextOverride = MediaQuery.boldTextOverride(context);
|
||||
outsideBoldTextOverride = MediaQuery.boldTextOf(context);
|
||||
return MediaQuery(
|
||||
data: const MediaQueryData(
|
||||
boldText: true,
|
||||
),
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
insideBoldTextOverride = MediaQuery.boldTextOverride(context);
|
||||
insideBoldTextOverride = MediaQuery.boldTextOf(context);
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
@ -937,4 +937,80 @@ void main() {
|
||||
expect(MediaQueryData.fromWindow(tester.binding.window).gestureSettings.touchSlop, closeTo(33.33, 0.1)); // Repeating, of course
|
||||
tester.binding.window.viewConfigurationTestValue = null;
|
||||
});
|
||||
|
||||
testWidgets('MediaQuery can be partially depended-on', (WidgetTester tester) async {
|
||||
MediaQueryData data = const MediaQueryData(
|
||||
size: Size(800, 600),
|
||||
textScaleFactor: 1.1
|
||||
);
|
||||
|
||||
int sizeBuildCount = 0;
|
||||
int textScaleFactorBuildCount = 0;
|
||||
|
||||
final Widget showSize = Builder(
|
||||
builder: (BuildContext context) {
|
||||
sizeBuildCount++;
|
||||
return Text('size: ${MediaQuery.sizeOf(context)}');
|
||||
}
|
||||
);
|
||||
|
||||
final Widget showTextScaleFactor = Builder(
|
||||
builder: (BuildContext context) {
|
||||
textScaleFactorBuildCount++;
|
||||
return Text('textScaleFactor: ${MediaQuery.textScaleFactorOf(context).toStringAsFixed(1)}');
|
||||
}
|
||||
);
|
||||
|
||||
final Widget page = StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return MediaQuery(
|
||||
data: data,
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
showSize,
|
||||
showTextScaleFactor,
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
data = data.copyWith(size: Size(data.size.width + 100, data.size.height));
|
||||
});
|
||||
},
|
||||
child: const Text('Increase width by 100')
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
data = data.copyWith(textScaleFactor: data.textScaleFactor + 0.1);
|
||||
});
|
||||
},
|
||||
child: const Text('Increase textScaleFactor by 0.1')
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
await tester.pumpWidget(MaterialApp(home: page));
|
||||
expect(find.text('size: Size(800.0, 600.0)'), findsOneWidget);
|
||||
expect(find.text('textScaleFactor: 1.1'), findsOneWidget);
|
||||
expect(sizeBuildCount, 1);
|
||||
expect(textScaleFactorBuildCount, 1);
|
||||
|
||||
await tester.tap(find.text('Increase width by 100'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('size: Size(900.0, 600.0)'), findsOneWidget);
|
||||
expect(find.text('textScaleFactor: 1.1'), findsOneWidget);
|
||||
expect(sizeBuildCount, 2);
|
||||
expect(textScaleFactorBuildCount, 1);
|
||||
|
||||
await tester.tap(find.text('Increase textScaleFactor by 0.1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('size: Size(900.0, 600.0)'), findsOneWidget);
|
||||
expect(find.text('textScaleFactor: 1.2'), findsOneWidget);
|
||||
expect(sizeBuildCount, 2);
|
||||
expect(textScaleFactorBuildCount, 2);
|
||||
});
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class TestOrientedBox extends SingleChildRenderObjectWidget {
|
||||
const TestOrientedBox({ super.key, super.child });
|
||||
|
||||
Decoration _getDecoration(BuildContext context) {
|
||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||
final Orientation orientation = MediaQuery.orientationOf(context);
|
||||
switch (orientation) {
|
||||
case Orientation.landscape:
|
||||
return const BoxDecoration(color: Color(0xFF00FF00));
|
||||
|
@ -235,4 +235,7 @@ void main() {
|
||||
scrollBehavior.buildViewportChrome(context, child, axisDirection);
|
||||
final CupertinoScrollBehavior cupertinoScrollBehavior = CupertinoScrollBehavior();
|
||||
cupertinoScrollBehavior.buildViewportChrome(context, child, axisDirection);
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/114459
|
||||
MediaQuery.boldTextOverride(context);
|
||||
}
|
||||
|
@ -235,4 +235,7 @@ void main() {
|
||||
scrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
|
||||
final CupertinoScrollBehavior cupertinoScrollBehavior = CupertinoScrollBehavior();
|
||||
cupertinoScrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/114459
|
||||
MediaQuery.boldTextOf(context);
|
||||
}
|
||||
|
@ -307,4 +307,7 @@ void main() {
|
||||
ScrollbarThemeData scrollbarTheme = ScrollbarThemeData(showTrackOnHover: nowShowing);
|
||||
scrollbarTheme.copyWith(showTrackOnHover: nowShowing);
|
||||
scrollbarTheme.showTrackOnHover;
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/114459
|
||||
MediaQuery.boldTextOverride(context);
|
||||
}
|
||||
|
@ -303,4 +303,7 @@ void main() {
|
||||
ScrollbarThemeData scrollbarTheme = ScrollbarThemeData(trackVisibility: nowShowing);
|
||||
scrollbarTheme.copyWith(trackVisibility: nowShowing);
|
||||
scrollbarTheme.trackVisibility;
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/114459
|
||||
MediaQuery.boldTextOf(context);
|
||||
}
|
||||
|
@ -150,4 +150,7 @@ void main() {
|
||||
// Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
final ScrollBehavior scrollBehavior = ScrollBehavior();
|
||||
scrollBehavior.buildViewportChrome(context, child, axisDirection);
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/114459
|
||||
MediaQuery.boldTextOverride(context);
|
||||
}
|
||||
|
@ -150,4 +150,7 @@ void main() {
|
||||
// Changes made in https://github.com/flutter/flutter/pull/78588
|
||||
final ScrollBehavior scrollBehavior = ScrollBehavior();
|
||||
scrollBehavior.buildOverscrollIndicator(context, child, axisDirection);
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/114459
|
||||
MediaQuery.boldTextOf(context);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user