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)
I was poking around
BuildContextAPIs and tried to invokevisitAncestorElements()all the way up the tree. I invokedvisitAncestorElements()from my widget'sbuild()method. I ran into a null pointer error for_offstageinOverlayat:flutter/packages/flutter/lib/src/widgets/overlay.dart
Line 566 in a3cbe25
The error was:
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: