diff --git a/packages/flutter/lib/src/material/menu_anchor.dart b/packages/flutter/lib/src/material/menu_anchor.dart index 06388ad0e3da..0789aae70b65 100644 --- a/packages/flutter/lib/src/material/menu_anchor.dart +++ b/packages/flutter/lib/src/material/menu_anchor.dart @@ -362,7 +362,7 @@ class _MenuAnchorState extends State { ); } - return _MenuAnchorMarker( + return _MenuAnchorScope( anchorKey: _anchorKey, anchor: this, isOpen: _isOpen, @@ -511,7 +511,7 @@ class _MenuAnchorState extends State { // Copy all the themes from the supplied outer context to the // overlay. outerContext, - _MenuAnchorMarker( + _MenuAnchorScope( // Re-advertize the anchor here in the overlay, since // otherwise a search for the anchor by descendants won't find // it. @@ -571,7 +571,7 @@ class _MenuAnchorState extends State { // dependency relationship that will rebuild the context when the node // changes. static _MenuAnchorState? _maybeOf(BuildContext context) { - return context.dependOnInheritedWidgetOfExactType<_MenuAnchorMarker>()?.anchor; + return context.dependOnInheritedWidgetOfExactType<_MenuAnchorScope>()?.anchor; } } @@ -2195,8 +2195,8 @@ class _LocalizedShortcutLabeler { } } -class _MenuAnchorMarker extends InheritedWidget { - const _MenuAnchorMarker({ +class _MenuAnchorScope extends InheritedWidget { + const _MenuAnchorScope({ required super.child, required this.anchorKey, required this.anchor, @@ -2208,7 +2208,7 @@ class _MenuAnchorMarker extends InheritedWidget { final bool isOpen; @override - bool updateShouldNotify(_MenuAnchorMarker oldWidget) { + bool updateShouldNotify(_MenuAnchorScope oldWidget) { return anchorKey != oldWidget.anchorKey || anchor != oldWidget.anchor || isOpen != oldWidget.isOpen; diff --git a/packages/flutter/lib/src/widgets/actions.dart b/packages/flutter/lib/src/widgets/actions.dart index 8cd8dfc209d0..e99e4eaf9881 100644 --- a/packages/flutter/lib/src/widgets/actions.dart +++ b/packages/flutter/lib/src/widgets/actions.dart @@ -681,7 +681,7 @@ class Actions extends StatefulWidget { // getElementForInheritedWidgetOfExactType. Returns true if the visitor found // what it was looking for. static bool _visitActionsAncestors(BuildContext context, bool Function(InheritedElement element) visitor) { - InheritedElement? actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsMarker>(); + InheritedElement? actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsScope>(); while (actionsElement != null) { if (visitor(actionsElement) == true) { break; @@ -690,7 +690,7 @@ class Actions extends StatefulWidget { // context.getElementForInheritedWidgetOfExactType will return itself if it // happens to be of the correct type. final BuildContext parent = _getParent(actionsElement); - actionsElement = parent.getElementForInheritedWidgetOfExactType<_ActionsMarker>(); + actionsElement = parent.getElementForInheritedWidgetOfExactType<_ActionsScope>(); } return actionsElement != null; } @@ -700,7 +700,7 @@ class Actions extends StatefulWidget { static ActionDispatcher _findDispatcher(BuildContext context) { ActionDispatcher? dispatcher; _visitActionsAncestors(context, (InheritedElement element) { - final ActionDispatcher? found = (element.widget as _ActionsMarker).dispatcher; + final ActionDispatcher? found = (element.widget as _ActionsScope).dispatcher; if (found != null) { dispatcher = found; return true; @@ -807,7 +807,7 @@ class Actions extends StatefulWidget { ); _visitActionsAncestors(context, (InheritedElement element) { - final _ActionsMarker actions = element.widget as _ActionsMarker; + final _ActionsScope actions = element.widget as _ActionsScope; final Action? result = _castAction(actions, intent: intent); if (result != null) { context.dependOnInheritedElement(element); @@ -836,7 +836,7 @@ class Actions extends StatefulWidget { ); _visitActionsAncestors(context, (InheritedElement element) { - final _ActionsMarker actions = element.widget as _ActionsMarker; + final _ActionsScope actions = element.widget as _ActionsScope; final Action? result = _castAction(actions, intent: intent); if (result != null) { action = result; @@ -849,8 +849,8 @@ class Actions extends StatefulWidget { } // Find the [Action] that handles the given `intent` in the given - // `_ActionsMarker`, and verify it has the right type parameter. - static Action? _castAction(_ActionsMarker actionsMarker, { T? intent }) { + // `_ActionsScope`, and verify it has the right type parameter. + static Action? _castAction(_ActionsScope actionsMarker, { T? intent }) { final Action? mappedAction = actionsMarker.actions[intent?.runtimeType ?? T]; if (mappedAction is Action?) { return mappedAction; @@ -870,7 +870,7 @@ class Actions extends StatefulWidget { /// widget is found. static ActionDispatcher of(BuildContext context) { assert(context != null); - final _ActionsMarker? marker = context.dependOnInheritedWidgetOfExactType<_ActionsMarker>(); + final _ActionsScope? marker = context.dependOnInheritedWidgetOfExactType<_ActionsScope>(); return marker?.dispatcher ?? _findDispatcher(context); } @@ -897,7 +897,7 @@ class Actions extends StatefulWidget { Object? returnValue; final bool actionFound = _visitActionsAncestors(context, (InheritedElement element) { - final _ActionsMarker actions = element.widget as _ActionsMarker; + final _ActionsScope actions = element.widget as _ActionsScope; final Action? result = _castAction(actions, intent: intent); if (result != null && result.isEnabled(intent)) { // Invoke the action we found using the relevant dispatcher from the Actions @@ -950,7 +950,7 @@ class Actions extends StatefulWidget { Object? returnValue; _visitActionsAncestors(context, (InheritedElement element) { - final _ActionsMarker actions = element.widget as _ActionsMarker; + final _ActionsScope actions = element.widget as _ActionsScope; final Action? result = _castAction(actions, intent: intent); if (result != null && result.isEnabled(intent)) { // Invoke the action we found using the relevant dispatcher from the Actions @@ -1024,7 +1024,7 @@ class _ActionsState extends State { @override Widget build(BuildContext context) { - return _ActionsMarker( + return _ActionsScope( actions: widget.actions, dispatcher: widget.dispatcher, rebuildKey: rebuildKey, @@ -1035,8 +1035,8 @@ class _ActionsState extends State { // An inherited widget used by Actions widget for fast lookup of the Actions // widget information. -class _ActionsMarker extends InheritedWidget { - const _ActionsMarker({ +class _ActionsScope extends InheritedWidget { + const _ActionsScope({ required this.dispatcher, required this.actions, required this.rebuildKey, @@ -1049,7 +1049,7 @@ class _ActionsMarker extends InheritedWidget { final Object rebuildKey; @override - bool updateShouldNotify(_ActionsMarker oldWidget) { + bool updateShouldNotify(_ActionsScope oldWidget) { return rebuildKey != oldWidget.rebuildKey || oldWidget.dispatcher != dispatcher || !mapEquals>(oldWidget.actions, actions); diff --git a/packages/flutter/lib/src/widgets/focus_scope.dart b/packages/flutter/lib/src/widgets/focus_scope.dart index f967aa208c96..f908d32ec940 100644 --- a/packages/flutter/lib/src/widgets/focus_scope.dart +++ b/packages/flutter/lib/src/widgets/focus_scope.dart @@ -388,7 +388,7 @@ class Focus extends StatefulWidget { static FocusNode of(BuildContext context, { bool scopeOk = false }) { assert(context != null); assert(scopeOk != null); - final _FocusMarker? marker = context.dependOnInheritedWidgetOfExactType<_FocusMarker>(); + final _FocusInheritedScope? marker = context.dependOnInheritedWidgetOfExactType<_FocusInheritedScope>(); final FocusNode? node = marker?.notifier; assert(() { if (node == null) { @@ -440,7 +440,7 @@ class Focus extends StatefulWidget { static FocusNode? maybeOf(BuildContext context, { bool scopeOk = false }) { assert(context != null); assert(scopeOk != null); - final _FocusMarker? marker = context.dependOnInheritedWidgetOfExactType<_FocusMarker>(); + final _FocusInheritedScope? marker = context.dependOnInheritedWidgetOfExactType<_FocusInheritedScope>(); final FocusNode? node = marker?.notifier; if (node == null) { return null; @@ -686,7 +686,7 @@ class _FocusState extends State { child: widget.child, ); } - return _FocusMarker( + return _FocusInheritedScope( node: focusNode, child: child, ); @@ -798,7 +798,7 @@ class FocusScope extends Focus { /// The [context] argument must not be null. static FocusScopeNode of(BuildContext context) { assert(context != null); - final _FocusMarker? marker = context.dependOnInheritedWidgetOfExactType<_FocusMarker>(); + final _FocusInheritedScope? marker = context.dependOnInheritedWidgetOfExactType<_FocusInheritedScope>(); return marker?.notifier?.nearestScope ?? context.owner!.focusManager.rootScope; } @@ -853,7 +853,7 @@ class _FocusScopeState extends _FocusState { _focusAttachment!.reparent(parent: widget.parentNode); return Semantics( explicitChildNodes: true, - child: _FocusMarker( + child: _FocusInheritedScope( node: focusNode, child: widget.child, ), @@ -861,9 +861,9 @@ class _FocusScopeState extends _FocusState { } } -// The InheritedWidget marker for Focus and FocusScope. -class _FocusMarker extends InheritedNotifier { - const _FocusMarker({ +// The InheritedWidget for Focus and FocusScope. +class _FocusInheritedScope extends InheritedNotifier { + const _FocusInheritedScope({ required FocusNode node, required super.child, }) : assert(node != null), diff --git a/packages/flutter/lib/src/widgets/focus_traversal.dart b/packages/flutter/lib/src/widgets/focus_traversal.dart index af7f3cd2cea7..4bd503dbfd3c 100644 --- a/packages/flutter/lib/src/widgets/focus_traversal.dart +++ b/packages/flutter/lib/src/widgets/focus_traversal.dart @@ -47,7 +47,7 @@ void _focusAndEnsureVisible( // sorting their contents. class _FocusTraversalGroupInfo { _FocusTraversalGroupInfo( - _FocusTraversalGroupMarker? marker, { + _FocusTraversalGroupScope? marker, { FocusTraversalPolicy? defaultPolicy, List? members, }) : groupNode = marker?.focusNode, @@ -319,20 +319,20 @@ abstract class FocusTraversalPolicy with Diagnosticable { @protected Iterable sortDescendants(Iterable descendants, FocusNode currentNode); - _FocusTraversalGroupMarker? _getMarker(BuildContext? context) { - return context?.getElementForInheritedWidgetOfExactType<_FocusTraversalGroupMarker>()?.widget as _FocusTraversalGroupMarker?; + _FocusTraversalGroupScope? _getMarker(BuildContext? context) { + return context?.getElementForInheritedWidgetOfExactType<_FocusTraversalGroupScope>()?.widget as _FocusTraversalGroupScope?; } // Sort all descendants, taking into account the FocusTraversalGroup // that they are each in, and filtering out non-traversable/focusable nodes. List _sortAllDescendants(FocusScopeNode scope, FocusNode currentNode) { assert(scope != null); - final _FocusTraversalGroupMarker? scopeGroupMarker = _getMarker(scope.context); + final _FocusTraversalGroupScope? scopeGroupMarker = _getMarker(scope.context); final FocusTraversalPolicy defaultPolicy = scopeGroupMarker?.policy ?? ReadingOrderTraversalPolicy(); // Build the sorting data structure, separating descendants into groups. final Map groups = {}; for (final FocusNode node in scope.descendants) { - final _FocusTraversalGroupMarker? groupMarker = _getMarker(node.context); + final _FocusTraversalGroupScope? groupMarker = _getMarker(node.context); final FocusNode? groupNode = groupMarker?.focusNode; // Group nodes need to be added to their parent's node, or to the "null" // node if no parent is found. This creates the hierarchy of group nodes @@ -344,7 +344,7 @@ abstract class FocusTraversalPolicy with Diagnosticable { // looking with that node's parent, since _getMarker will return the // context it was called on if it matches the type. final BuildContext? parentContext = _getAncestor(groupNode!.context!, count: 2); - final _FocusTraversalGroupMarker? parentMarker = _getMarker(parentContext); + final _FocusTraversalGroupScope? parentMarker = _getMarker(parentContext); final FocusNode? parentNode = parentMarker?.focusNode; groups[parentNode] ??= _FocusTraversalGroupInfo(parentMarker, members: [], defaultPolicy: defaultPolicy); assert(!groups[parentNode]!.members.contains(node)); @@ -1586,7 +1586,7 @@ class FocusTraversalGroup extends StatefulWidget { /// [FocusTraversalGroup] ancestor is found. static FocusTraversalPolicy of(BuildContext context) { assert(context != null); - final _FocusTraversalGroupMarker? inherited = context.dependOnInheritedWidgetOfExactType<_FocusTraversalGroupMarker>(); + final _FocusTraversalGroupScope? inherited = context.dependOnInheritedWidgetOfExactType<_FocusTraversalGroupScope>(); assert(() { if (inherited == null) { throw FlutterError( @@ -1621,7 +1621,7 @@ class FocusTraversalGroup extends StatefulWidget { /// ancestor is found. static FocusTraversalPolicy? maybeOf(BuildContext context) { assert(context != null); - final _FocusTraversalGroupMarker? inherited = context.dependOnInheritedWidgetOfExactType<_FocusTraversalGroupMarker>(); + final _FocusTraversalGroupScope? inherited = context.dependOnInheritedWidgetOfExactType<_FocusTraversalGroupScope>(); return inherited?.policy; } @@ -1659,7 +1659,7 @@ class _FocusTraversalGroupState extends State { @override Widget build(BuildContext context) { - return _FocusTraversalGroupMarker( + return _FocusTraversalGroupScope( policy: widget.policy, focusNode: focusNode, child: Focus( @@ -1676,8 +1676,8 @@ class _FocusTraversalGroupState extends State { } // A "marker" inherited widget to make the group faster to find. -class _FocusTraversalGroupMarker extends InheritedWidget { - const _FocusTraversalGroupMarker({ +class _FocusTraversalGroupScope extends InheritedWidget { + const _FocusTraversalGroupScope({ required this.policy, required this.focusNode, required super.child, diff --git a/packages/flutter/lib/src/widgets/shortcuts.dart b/packages/flutter/lib/src/widgets/shortcuts.dart index e7b8ba19c2ec..1fba42b101e2 100644 --- a/packages/flutter/lib/src/widgets/shortcuts.dart +++ b/packages/flutter/lib/src/widgets/shortcuts.dart @@ -1277,8 +1277,8 @@ class ShortcutRegistry with ChangeNotifier { /// it doesn't find a [ShortcutRegistrar] ancestor. static ShortcutRegistry of(BuildContext context) { assert(context != null); - final _ShortcutRegistrarMarker? inherited = - context.dependOnInheritedWidgetOfExactType<_ShortcutRegistrarMarker>(); + final _ShortcutRegistrarScope? inherited = + context.dependOnInheritedWidgetOfExactType<_ShortcutRegistrarScope>(); assert(() { if (inherited == null) { throw FlutterError( @@ -1313,8 +1313,8 @@ class ShortcutRegistry with ChangeNotifier { /// [ShortcutRegistrar] ancestor. static ShortcutRegistry? maybeOf(BuildContext context) { assert(context != null); - final _ShortcutRegistrarMarker? inherited = - context.dependOnInheritedWidgetOfExactType<_ShortcutRegistrarMarker>(); + final _ShortcutRegistrarScope? inherited = + context.dependOnInheritedWidgetOfExactType<_ShortcutRegistrarScope>(); return inherited?.registry; } @@ -1431,7 +1431,7 @@ class _ShortcutRegistrarState extends State { @override Widget build(BuildContext context) { - return _ShortcutRegistrarMarker( + return _ShortcutRegistrarScope( registry: registry, child: Shortcuts.manager( manager: manager, @@ -1441,8 +1441,8 @@ class _ShortcutRegistrarState extends State { } } -class _ShortcutRegistrarMarker extends InheritedWidget { - const _ShortcutRegistrarMarker({ +class _ShortcutRegistrarScope extends InheritedWidget { + const _ShortcutRegistrarScope({ required this.registry, required super.child, }); @@ -1450,7 +1450,7 @@ class _ShortcutRegistrarMarker extends InheritedWidget { final ShortcutRegistry registry; @override - bool updateShouldNotify(covariant _ShortcutRegistrarMarker oldWidget) { + bool updateShouldNotify(covariant _ShortcutRegistrarScope oldWidget) { return registry != oldWidget.registry; } } diff --git a/packages/flutter/test/material/debug_test.dart b/packages/flutter/test/material/debug_test.dart index 8c49223c6593..b955a1cba29f 100644 --- a/packages/flutter/test/material/debug_test.dart +++ b/packages/flutter/test/material/debug_test.dart @@ -137,11 +137,11 @@ void main() { ' _FadeUpwardsPageTransition\n' ' AnimatedBuilder\n' ' RepaintBoundary\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Semantics\n' ' FocusScope\n' ' PrimaryScrollController\n' - ' _ActionsMarker\n' + ' _ActionsScope\n' ' Actions\n' ' Builder\n' ' PageStorage\n' @@ -158,17 +158,17 @@ void main() { ' _Theatre\n' ' Overlay-[LabeledGlobalKey#00000]\n' ' UnmanagedRestorationScope\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Focus\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Focus\n' - ' _FocusTraversalGroupMarker\n' + ' _FocusTraversalGroupScope\n' ' FocusTraversalGroup\n' ' AbsorbPointer\n' ' Listener\n' ' HeroControllerScope\n' ' Navigator-[GlobalObjectKey _WidgetsAppState#00000]\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Semantics\n' ' FocusScope\n' ' DefaultSelectionStyle\n' @@ -195,31 +195,31 @@ void main() { ' MediaQuery\n' ' _MediaQueryFromWindow\n' ' Semantics\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Focus\n' ' Shortcuts\n' - ' _ShortcutRegistrarMarker\n' + ' _ShortcutRegistrarScope\n' ' ShortcutRegistrar\n' ' TapRegionSurface\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Focus\n' - ' _FocusTraversalGroupMarker\n' + ' _FocusTraversalGroupScope\n' ' FocusTraversalGroup\n' - ' _ActionsMarker\n' + ' _ActionsScope\n' ' Actions\n' '${kIsWeb ? ' Semantics\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Focus\n' ' Shortcuts\n' : ''}' ' Semantics\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Focus\n' ' Shortcuts\n' ' DefaultTextEditingShortcuts\n' ' Semantics\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Focus\n' ' Shortcuts\n' ' _SharedAppModel\n' @@ -230,7 +230,7 @@ void main() { ' RootRestorationScope\n' ' WidgetsApp-[GlobalObjectKey _MaterialAppState#00000]\n' ' Semantics\n' - ' _FocusMarker\n' + ' _FocusInheritedScope\n' ' Focus\n' ' HeroControllerScope\n' ' ScrollConfiguration\n' @@ -362,7 +362,7 @@ void main() { ' MediaQuery\n' ' LayoutId-[<_ScaffoldSlot.snackBar>]\n' ' CustomMultiChildLayout\n' - ' _ActionsMarker\n' + ' _ActionsScope\n' ' Actions\n' ' AnimatedBuilder\n' ' DefaultTextStyle\n' diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index 8e69edb43bf8..be80d8ef478e 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -2443,7 +2443,7 @@ void main() { ' MediaQuery\n' ' LayoutId-[<_ScaffoldSlot.body>]\n' ' CustomMultiChildLayout\n' - ' _ActionsMarker\n' + ' _ActionsScope\n' ' Actions\n' ' AnimatedBuilder\n' ' DefaultTextStyle\n' diff --git a/packages/flutter/test/widgets/platform_view_test.dart b/packages/flutter/test/widgets/platform_view_test.dart index a79fd7e64264..0c9397cdd308 100644 --- a/packages/flutter/test/widgets/platform_view_test.dart +++ b/packages/flutter/test/widgets/platform_view_test.dart @@ -2494,7 +2494,7 @@ void main() { expect( tester.allWidgets.map((Widget widget) => widget.runtimeType.toString()).toList(), - containsAllInOrder(['PlatformViewLink', 'Focus', '_FocusMarker', 'Semantics', 'PlatformViewSurface']), + containsAllInOrder(['PlatformViewLink', 'Focus', '_FocusInheritedScope', 'Semantics', 'PlatformViewSurface']), ); expect(createdPlatformViewId, currentViewId + 1); @@ -2591,7 +2591,7 @@ void main() { expect( tester.allWidgets.map((Widget widget) => widget.runtimeType.toString()).toList(), - containsAllInOrder(['PlatformViewLink', 'Focus', '_FocusMarker', 'Semantics', 'PlatformViewSurface']), + containsAllInOrder(['PlatformViewLink', 'Focus', '_FocusInheritedScope', 'Semantics', 'PlatformViewSurface']), ); expect(createdPlatformViewId, currentViewId + 1); @@ -2686,7 +2686,7 @@ void main() { expect( tester.allWidgets.map((Widget widget) => widget.runtimeType.toString()).toList(), - containsAllInOrder(['PlatformViewLink', 'Focus', '_FocusMarker', 'Semantics', 'PlatformViewSurface']), + containsAllInOrder(['PlatformViewLink', 'Focus', '_FocusInheritedScope', 'Semantics', 'PlatformViewSurface']), ); expect(createdPlatformViewId, currentViewId + 1);