Skip to content

Commit ae7b99e

Browse files
Rename _*Marker classes to be _*Scope, for consistency (#118070)
* Rename _*Marker classes to be _*Scope, for consistency * [EMPTY] Commit to refresh the tree that is currently red (#118062) * Fix remaining tests Co-authored-by: Drew Roen <[email protected]>
1 parent a3629a2 commit ae7b99e

File tree

8 files changed

+67
-67
lines changed

8 files changed

+67
-67
lines changed

packages/flutter/lib/src/material/menu_anchor.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ class _MenuAnchorState extends State<MenuAnchor> {
362362
);
363363
}
364364

365-
return _MenuAnchorMarker(
365+
return _MenuAnchorScope(
366366
anchorKey: _anchorKey,
367367
anchor: this,
368368
isOpen: _isOpen,
@@ -511,7 +511,7 @@ class _MenuAnchorState extends State<MenuAnchor> {
511511
// Copy all the themes from the supplied outer context to the
512512
// overlay.
513513
outerContext,
514-
_MenuAnchorMarker(
514+
_MenuAnchorScope(
515515
// Re-advertize the anchor here in the overlay, since
516516
// otherwise a search for the anchor by descendants won't find
517517
// it.
@@ -571,7 +571,7 @@ class _MenuAnchorState extends State<MenuAnchor> {
571571
// dependency relationship that will rebuild the context when the node
572572
// changes.
573573
static _MenuAnchorState? _maybeOf(BuildContext context) {
574-
return context.dependOnInheritedWidgetOfExactType<_MenuAnchorMarker>()?.anchor;
574+
return context.dependOnInheritedWidgetOfExactType<_MenuAnchorScope>()?.anchor;
575575
}
576576
}
577577

@@ -2195,8 +2195,8 @@ class _LocalizedShortcutLabeler {
21952195
}
21962196
}
21972197

2198-
class _MenuAnchorMarker extends InheritedWidget {
2199-
const _MenuAnchorMarker({
2198+
class _MenuAnchorScope extends InheritedWidget {
2199+
const _MenuAnchorScope({
22002200
required super.child,
22012201
required this.anchorKey,
22022202
required this.anchor,
@@ -2208,7 +2208,7 @@ class _MenuAnchorMarker extends InheritedWidget {
22082208
final bool isOpen;
22092209

22102210
@override
2211-
bool updateShouldNotify(_MenuAnchorMarker oldWidget) {
2211+
bool updateShouldNotify(_MenuAnchorScope oldWidget) {
22122212
return anchorKey != oldWidget.anchorKey
22132213
|| anchor != oldWidget.anchor
22142214
|| isOpen != oldWidget.isOpen;

packages/flutter/lib/src/widgets/actions.dart

+14-14
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ class Actions extends StatefulWidget {
681681
// getElementForInheritedWidgetOfExactType. Returns true if the visitor found
682682
// what it was looking for.
683683
static bool _visitActionsAncestors(BuildContext context, bool Function(InheritedElement element) visitor) {
684-
InheritedElement? actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsMarker>();
684+
InheritedElement? actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsScope>();
685685
while (actionsElement != null) {
686686
if (visitor(actionsElement) == true) {
687687
break;
@@ -690,7 +690,7 @@ class Actions extends StatefulWidget {
690690
// context.getElementForInheritedWidgetOfExactType will return itself if it
691691
// happens to be of the correct type.
692692
final BuildContext parent = _getParent(actionsElement);
693-
actionsElement = parent.getElementForInheritedWidgetOfExactType<_ActionsMarker>();
693+
actionsElement = parent.getElementForInheritedWidgetOfExactType<_ActionsScope>();
694694
}
695695
return actionsElement != null;
696696
}
@@ -700,7 +700,7 @@ class Actions extends StatefulWidget {
700700
static ActionDispatcher _findDispatcher(BuildContext context) {
701701
ActionDispatcher? dispatcher;
702702
_visitActionsAncestors(context, (InheritedElement element) {
703-
final ActionDispatcher? found = (element.widget as _ActionsMarker).dispatcher;
703+
final ActionDispatcher? found = (element.widget as _ActionsScope).dispatcher;
704704
if (found != null) {
705705
dispatcher = found;
706706
return true;
@@ -807,7 +807,7 @@ class Actions extends StatefulWidget {
807807
);
808808

809809
_visitActionsAncestors(context, (InheritedElement element) {
810-
final _ActionsMarker actions = element.widget as _ActionsMarker;
810+
final _ActionsScope actions = element.widget as _ActionsScope;
811811
final Action<T>? result = _castAction(actions, intent: intent);
812812
if (result != null) {
813813
context.dependOnInheritedElement(element);
@@ -836,7 +836,7 @@ class Actions extends StatefulWidget {
836836
);
837837

838838
_visitActionsAncestors(context, (InheritedElement element) {
839-
final _ActionsMarker actions = element.widget as _ActionsMarker;
839+
final _ActionsScope actions = element.widget as _ActionsScope;
840840
final Action<T>? result = _castAction(actions, intent: intent);
841841
if (result != null) {
842842
action = result;
@@ -849,8 +849,8 @@ class Actions extends StatefulWidget {
849849
}
850850

851851
// Find the [Action] that handles the given `intent` in the given
852-
// `_ActionsMarker`, and verify it has the right type parameter.
853-
static Action<T>? _castAction<T extends Intent>(_ActionsMarker actionsMarker, { T? intent }) {
852+
// `_ActionsScope`, and verify it has the right type parameter.
853+
static Action<T>? _castAction<T extends Intent>(_ActionsScope actionsMarker, { T? intent }) {
854854
final Action<Intent>? mappedAction = actionsMarker.actions[intent?.runtimeType ?? T];
855855
if (mappedAction is Action<T>?) {
856856
return mappedAction;
@@ -870,7 +870,7 @@ class Actions extends StatefulWidget {
870870
/// widget is found.
871871
static ActionDispatcher of(BuildContext context) {
872872
assert(context != null);
873-
final _ActionsMarker? marker = context.dependOnInheritedWidgetOfExactType<_ActionsMarker>();
873+
final _ActionsScope? marker = context.dependOnInheritedWidgetOfExactType<_ActionsScope>();
874874
return marker?.dispatcher ?? _findDispatcher(context);
875875
}
876876

@@ -897,7 +897,7 @@ class Actions extends StatefulWidget {
897897
Object? returnValue;
898898

899899
final bool actionFound = _visitActionsAncestors(context, (InheritedElement element) {
900-
final _ActionsMarker actions = element.widget as _ActionsMarker;
900+
final _ActionsScope actions = element.widget as _ActionsScope;
901901
final Action<T>? result = _castAction(actions, intent: intent);
902902
if (result != null && result.isEnabled(intent)) {
903903
// Invoke the action we found using the relevant dispatcher from the Actions
@@ -950,7 +950,7 @@ class Actions extends StatefulWidget {
950950
Object? returnValue;
951951

952952
_visitActionsAncestors(context, (InheritedElement element) {
953-
final _ActionsMarker actions = element.widget as _ActionsMarker;
953+
final _ActionsScope actions = element.widget as _ActionsScope;
954954
final Action<T>? result = _castAction(actions, intent: intent);
955955
if (result != null && result.isEnabled(intent)) {
956956
// Invoke the action we found using the relevant dispatcher from the Actions
@@ -1024,7 +1024,7 @@ class _ActionsState extends State<Actions> {
10241024

10251025
@override
10261026
Widget build(BuildContext context) {
1027-
return _ActionsMarker(
1027+
return _ActionsScope(
10281028
actions: widget.actions,
10291029
dispatcher: widget.dispatcher,
10301030
rebuildKey: rebuildKey,
@@ -1035,8 +1035,8 @@ class _ActionsState extends State<Actions> {
10351035

10361036
// An inherited widget used by Actions widget for fast lookup of the Actions
10371037
// widget information.
1038-
class _ActionsMarker extends InheritedWidget {
1039-
const _ActionsMarker({
1038+
class _ActionsScope extends InheritedWidget {
1039+
const _ActionsScope({
10401040
required this.dispatcher,
10411041
required this.actions,
10421042
required this.rebuildKey,
@@ -1049,7 +1049,7 @@ class _ActionsMarker extends InheritedWidget {
10491049
final Object rebuildKey;
10501050

10511051
@override
1052-
bool updateShouldNotify(_ActionsMarker oldWidget) {
1052+
bool updateShouldNotify(_ActionsScope oldWidget) {
10531053
return rebuildKey != oldWidget.rebuildKey
10541054
|| oldWidget.dispatcher != dispatcher
10551055
|| !mapEquals<Type, Action<Intent>>(oldWidget.actions, actions);

packages/flutter/lib/src/widgets/focus_scope.dart

+8-8
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class Focus extends StatefulWidget {
388388
static FocusNode of(BuildContext context, { bool scopeOk = false }) {
389389
assert(context != null);
390390
assert(scopeOk != null);
391-
final _FocusMarker? marker = context.dependOnInheritedWidgetOfExactType<_FocusMarker>();
391+
final _FocusInheritedScope? marker = context.dependOnInheritedWidgetOfExactType<_FocusInheritedScope>();
392392
final FocusNode? node = marker?.notifier;
393393
assert(() {
394394
if (node == null) {
@@ -440,7 +440,7 @@ class Focus extends StatefulWidget {
440440
static FocusNode? maybeOf(BuildContext context, { bool scopeOk = false }) {
441441
assert(context != null);
442442
assert(scopeOk != null);
443-
final _FocusMarker? marker = context.dependOnInheritedWidgetOfExactType<_FocusMarker>();
443+
final _FocusInheritedScope? marker = context.dependOnInheritedWidgetOfExactType<_FocusInheritedScope>();
444444
final FocusNode? node = marker?.notifier;
445445
if (node == null) {
446446
return null;
@@ -686,7 +686,7 @@ class _FocusState extends State<Focus> {
686686
child: widget.child,
687687
);
688688
}
689-
return _FocusMarker(
689+
return _FocusInheritedScope(
690690
node: focusNode,
691691
child: child,
692692
);
@@ -798,7 +798,7 @@ class FocusScope extends Focus {
798798
/// The [context] argument must not be null.
799799
static FocusScopeNode of(BuildContext context) {
800800
assert(context != null);
801-
final _FocusMarker? marker = context.dependOnInheritedWidgetOfExactType<_FocusMarker>();
801+
final _FocusInheritedScope? marker = context.dependOnInheritedWidgetOfExactType<_FocusInheritedScope>();
802802
return marker?.notifier?.nearestScope ?? context.owner!.focusManager.rootScope;
803803
}
804804

@@ -853,17 +853,17 @@ class _FocusScopeState extends _FocusState {
853853
_focusAttachment!.reparent(parent: widget.parentNode);
854854
return Semantics(
855855
explicitChildNodes: true,
856-
child: _FocusMarker(
856+
child: _FocusInheritedScope(
857857
node: focusNode,
858858
child: widget.child,
859859
),
860860
);
861861
}
862862
}
863863

864-
// The InheritedWidget marker for Focus and FocusScope.
865-
class _FocusMarker extends InheritedNotifier<FocusNode> {
866-
const _FocusMarker({
864+
// The InheritedWidget for Focus and FocusScope.
865+
class _FocusInheritedScope extends InheritedNotifier<FocusNode> {
866+
const _FocusInheritedScope({
867867
required FocusNode node,
868868
required super.child,
869869
}) : assert(node != null),

packages/flutter/lib/src/widgets/focus_traversal.dart

+11-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void _focusAndEnsureVisible(
4747
// sorting their contents.
4848
class _FocusTraversalGroupInfo {
4949
_FocusTraversalGroupInfo(
50-
_FocusTraversalGroupMarker? marker, {
50+
_FocusTraversalGroupScope? marker, {
5151
FocusTraversalPolicy? defaultPolicy,
5252
List<FocusNode>? members,
5353
}) : groupNode = marker?.focusNode,
@@ -319,20 +319,20 @@ abstract class FocusTraversalPolicy with Diagnosticable {
319319
@protected
320320
Iterable<FocusNode> sortDescendants(Iterable<FocusNode> descendants, FocusNode currentNode);
321321

322-
_FocusTraversalGroupMarker? _getMarker(BuildContext? context) {
323-
return context?.getElementForInheritedWidgetOfExactType<_FocusTraversalGroupMarker>()?.widget as _FocusTraversalGroupMarker?;
322+
_FocusTraversalGroupScope? _getMarker(BuildContext? context) {
323+
return context?.getElementForInheritedWidgetOfExactType<_FocusTraversalGroupScope>()?.widget as _FocusTraversalGroupScope?;
324324
}
325325

326326
// Sort all descendants, taking into account the FocusTraversalGroup
327327
// that they are each in, and filtering out non-traversable/focusable nodes.
328328
List<FocusNode> _sortAllDescendants(FocusScopeNode scope, FocusNode currentNode) {
329329
assert(scope != null);
330-
final _FocusTraversalGroupMarker? scopeGroupMarker = _getMarker(scope.context);
330+
final _FocusTraversalGroupScope? scopeGroupMarker = _getMarker(scope.context);
331331
final FocusTraversalPolicy defaultPolicy = scopeGroupMarker?.policy ?? ReadingOrderTraversalPolicy();
332332
// Build the sorting data structure, separating descendants into groups.
333333
final Map<FocusNode?, _FocusTraversalGroupInfo> groups = <FocusNode?, _FocusTraversalGroupInfo>{};
334334
for (final FocusNode node in scope.descendants) {
335-
final _FocusTraversalGroupMarker? groupMarker = _getMarker(node.context);
335+
final _FocusTraversalGroupScope? groupMarker = _getMarker(node.context);
336336
final FocusNode? groupNode = groupMarker?.focusNode;
337337
// Group nodes need to be added to their parent's node, or to the "null"
338338
// node if no parent is found. This creates the hierarchy of group nodes
@@ -344,7 +344,7 @@ abstract class FocusTraversalPolicy with Diagnosticable {
344344
// looking with that node's parent, since _getMarker will return the
345345
// context it was called on if it matches the type.
346346
final BuildContext? parentContext = _getAncestor(groupNode!.context!, count: 2);
347-
final _FocusTraversalGroupMarker? parentMarker = _getMarker(parentContext);
347+
final _FocusTraversalGroupScope? parentMarker = _getMarker(parentContext);
348348
final FocusNode? parentNode = parentMarker?.focusNode;
349349
groups[parentNode] ??= _FocusTraversalGroupInfo(parentMarker, members: <FocusNode>[], defaultPolicy: defaultPolicy);
350350
assert(!groups[parentNode]!.members.contains(node));
@@ -1586,7 +1586,7 @@ class FocusTraversalGroup extends StatefulWidget {
15861586
/// [FocusTraversalGroup] ancestor is found.
15871587
static FocusTraversalPolicy of(BuildContext context) {
15881588
assert(context != null);
1589-
final _FocusTraversalGroupMarker? inherited = context.dependOnInheritedWidgetOfExactType<_FocusTraversalGroupMarker>();
1589+
final _FocusTraversalGroupScope? inherited = context.dependOnInheritedWidgetOfExactType<_FocusTraversalGroupScope>();
15901590
assert(() {
15911591
if (inherited == null) {
15921592
throw FlutterError(
@@ -1621,7 +1621,7 @@ class FocusTraversalGroup extends StatefulWidget {
16211621
/// ancestor is found.
16221622
static FocusTraversalPolicy? maybeOf(BuildContext context) {
16231623
assert(context != null);
1624-
final _FocusTraversalGroupMarker? inherited = context.dependOnInheritedWidgetOfExactType<_FocusTraversalGroupMarker>();
1624+
final _FocusTraversalGroupScope? inherited = context.dependOnInheritedWidgetOfExactType<_FocusTraversalGroupScope>();
16251625
return inherited?.policy;
16261626
}
16271627

@@ -1659,7 +1659,7 @@ class _FocusTraversalGroupState extends State<FocusTraversalGroup> {
16591659

16601660
@override
16611661
Widget build(BuildContext context) {
1662-
return _FocusTraversalGroupMarker(
1662+
return _FocusTraversalGroupScope(
16631663
policy: widget.policy,
16641664
focusNode: focusNode,
16651665
child: Focus(
@@ -1676,8 +1676,8 @@ class _FocusTraversalGroupState extends State<FocusTraversalGroup> {
16761676
}
16771677

16781678
// A "marker" inherited widget to make the group faster to find.
1679-
class _FocusTraversalGroupMarker extends InheritedWidget {
1680-
const _FocusTraversalGroupMarker({
1679+
class _FocusTraversalGroupScope extends InheritedWidget {
1680+
const _FocusTraversalGroupScope({
16811681
required this.policy,
16821682
required this.focusNode,
16831683
required super.child,

packages/flutter/lib/src/widgets/shortcuts.dart

+8-8
Original file line numberDiff line numberDiff line change
@@ -1277,8 +1277,8 @@ class ShortcutRegistry with ChangeNotifier {
12771277
/// it doesn't find a [ShortcutRegistrar] ancestor.
12781278
static ShortcutRegistry of(BuildContext context) {
12791279
assert(context != null);
1280-
final _ShortcutRegistrarMarker? inherited =
1281-
context.dependOnInheritedWidgetOfExactType<_ShortcutRegistrarMarker>();
1280+
final _ShortcutRegistrarScope? inherited =
1281+
context.dependOnInheritedWidgetOfExactType<_ShortcutRegistrarScope>();
12821282
assert(() {
12831283
if (inherited == null) {
12841284
throw FlutterError(
@@ -1313,8 +1313,8 @@ class ShortcutRegistry with ChangeNotifier {
13131313
/// [ShortcutRegistrar] ancestor.
13141314
static ShortcutRegistry? maybeOf(BuildContext context) {
13151315
assert(context != null);
1316-
final _ShortcutRegistrarMarker? inherited =
1317-
context.dependOnInheritedWidgetOfExactType<_ShortcutRegistrarMarker>();
1316+
final _ShortcutRegistrarScope? inherited =
1317+
context.dependOnInheritedWidgetOfExactType<_ShortcutRegistrarScope>();
13181318
return inherited?.registry;
13191319
}
13201320

@@ -1431,7 +1431,7 @@ class _ShortcutRegistrarState extends State<ShortcutRegistrar> {
14311431

14321432
@override
14331433
Widget build(BuildContext context) {
1434-
return _ShortcutRegistrarMarker(
1434+
return _ShortcutRegistrarScope(
14351435
registry: registry,
14361436
child: Shortcuts.manager(
14371437
manager: manager,
@@ -1441,16 +1441,16 @@ class _ShortcutRegistrarState extends State<ShortcutRegistrar> {
14411441
}
14421442
}
14431443

1444-
class _ShortcutRegistrarMarker extends InheritedWidget {
1445-
const _ShortcutRegistrarMarker({
1444+
class _ShortcutRegistrarScope extends InheritedWidget {
1445+
const _ShortcutRegistrarScope({
14461446
required this.registry,
14471447
required super.child,
14481448
});
14491449

14501450
final ShortcutRegistry registry;
14511451

14521452
@override
1453-
bool updateShouldNotify(covariant _ShortcutRegistrarMarker oldWidget) {
1453+
bool updateShouldNotify(covariant _ShortcutRegistrarScope oldWidget) {
14541454
return registry != oldWidget.registry;
14551455
}
14561456
}

0 commit comments

Comments
 (0)