Unverified Commit c8bbb522 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Protect against null context in release mode (#64474)

parent ed65f5e9
...@@ -454,7 +454,7 @@ class Actions extends StatefulWidget { ...@@ -454,7 +454,7 @@ class Actions extends StatefulWidget {
// getElementForInheritedWidgetOfExactType. Returns true if the visitor found // getElementForInheritedWidgetOfExactType. Returns true if the visitor found
// what it was looking for. // what it was looking for.
static bool _visitActionsAncestors(BuildContext context, bool visitor(InheritedElement element)) { static bool _visitActionsAncestors(BuildContext context, bool visitor(InheritedElement element)) {
InheritedElement actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsMarker>(); InheritedElement actionsElement = context?.getElementForInheritedWidgetOfExactType<_ActionsMarker>();
while (actionsElement != null) { while (actionsElement != null) {
if (visitor(actionsElement) == true) { if (visitor(actionsElement) == true) {
break; break;
...@@ -463,7 +463,7 @@ class Actions extends StatefulWidget { ...@@ -463,7 +463,7 @@ class Actions extends StatefulWidget {
// context.getElementForInheritedWidgetOfExactType will return itself if it // context.getElementForInheritedWidgetOfExactType will return itself if it
// happens to be of the correct type. // happens to be of the correct type.
final BuildContext parent = _getParent(actionsElement); final BuildContext parent = _getParent(actionsElement);
actionsElement = parent.getElementForInheritedWidgetOfExactType<_ActionsMarker>(); actionsElement = parent?.getElementForInheritedWidgetOfExactType<_ActionsMarker>();
} }
return actionsElement != null; return actionsElement != null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment