-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: contributor-productivityTeam-specific productivity, code health, technical debt.Team-specific productivity, code health, technical debt.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
I was poking around BuildContext APIs and tried to invoke visitAncestorElements() all the way up the tree. I invoked visitAncestorElements() from my widget's build() method. I ran into a null pointer error for _offstage in Overlay at:
| for (Element child in _offstage) { |
The error was:
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following NoSuchMethodError was thrown building MyDescendant6(dirty):
flutter: The getter 'iterator' was called on null.
flutter: Receiver: null
flutter: Tried calling: iterator
flutter:
flutter: User-created ancestor of the error-causing widget was:
flutter: Padding
flutter: file:///Users/[redacted]/buildcontext_ancestors.dart:177:18
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
flutter: #1 _TheatreElement.visitChildren (package:flutter/src/widgets/overlay.dart:566:27)
...
It's possible that this error was the result of me mis-using the API, but in that case the API docs should probably be updated with the limitation, and maybe an appropriate error should be thrown when this happens.
Flutter Doctor:
• Flutter version 1.8.2-pre.216 at [redacted]
• Framework revision 24f483cf25 (5 hours ago), 2019-07-28 21:44:21 -0700
• Engine revision 38ac5f30a7
• Dart version 2.5.0 (build 2.5.0-dev.1.0 0ca1582afd)
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: contributor-productivityTeam-specific productivity, code health, technical debt.Team-specific productivity, code health, technical debt.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team