lukepighetti / flutter_hotspot

Simple tours, coachmarks, and tutorials. Just tag your Widgets!
https://pub.dev/packages/hotspot
MIT License
139 stars 14 forks source link

Error after start the flow and then open -> close a Dialog #8

Open EMUNES opened 3 months ago

EMUNES commented 3 months ago

Hello, after I wrap the View with HotspotProvider, things work as expected. However, if I quit or finish the flow after calling .startFlow(), later it will cause error if I then open and close a dialog. When I open a new dialog, the UI works fine but an exception will throw; When I close that dialog and return to the View using Navigator.pop(context), it will always report errors and the UI will all freeze, which I find no way to resolve.

If it helps, the hotspot is set on a FloatingActionButton under the Scaffold View wrapped by HotspotProvider, which is also the button to open that dialog. Is there a way to solve this problem?

Error message when enter the dialog:

E/flutter ( 8938): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/focus_manager.dart': Failed assertion: line 1299 pos 12: '_focusedChildren.isEmpty || _focusedChildren.last.enclosingScope == this': Focused child does not have the same idea of its enclosing scope as the scope does.
E/flutter ( 8938): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
E/flutter ( 8938): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter ( 8938): #2      FocusScopeNode.focusedChild (package:flutter/src/widgets/focus_manager.dart:1299:12)
E/flutter ( 8938): #3      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1384:17)
E/flutter ( 8938): #4      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1400:18)
E/flutter ( 8938): #5      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1400:18)
E/flutter ( 8938): #6      FocusNode.requestFocus (package:flutter/src/widgets/focus_manager.dart:1121:5)
E/flutter ( 8938): #7      Route.didPush.<anonymous closure> (package:flutter/src/widgets/navigator.dart:239:46)
E/flutter ( 8938): #8      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:847:45)
E/flutter ( 8938): #9      Future._propagateToListeners (dart:async/future_impl.dart:876:13)
E/flutter ( 8938): #10     Future._completeWithValue (dart:async/future_impl.dart:652:5)
E/flutter ( 8938): #11     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:722:7)
E/flutter ( 8938): #12     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter ( 8938): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter ( 8938): 

Error message when quit the dialog:

E/flutter ( 8938): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/focus_manager.dart': Failed assertion: line 1299 pos 12: '_focusedChildren.isEmpty || _focusedChildren.last.enclosingScope == this': Focused child does not have the same idea of its enclosing scope as the scope does.
E/flutter ( 8938): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
E/flutter ( 8938): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter ( 8938): #2      FocusScopeNode.focusedChild (package:flutter/src/widgets/focus_manager.dart:1299:12)
E/flutter ( 8938): #3      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1384:17)
E/flutter ( 8938): #4      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1400:18)
E/flutter ( 8938): #5      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1400:18)
E/flutter ( 8938): #6      FocusNode.requestFocus (package:flutter/src/widgets/focus_manager.dart:1121:5)
E/flutter ( 8938): #7      Route.didPush.<anonymous closure> (package:flutter/src/widgets/navigator.dart:239:46)
E/flutter ( 8938): #8      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:847:45)
E/flutter ( 8938): #9      Future._propagateToListeners (dart:async/future_impl.dart:876:13)
E/flutter ( 8938): #10     Future._completeWithValue (dart:async/future_impl.dart:652:5)
E/flutter ( 8938): #11     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:722:7)
E/flutter ( 8938): #12     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter ( 8938): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter ( 8938): 

======== Exception caught by gesture ===============================================================
The following assertion was thrown while handling a gesture:
Focused child does not have the same idea of its enclosing scope as the scope does.
'package:flutter/src/widgets/focus_manager.dart':
Failed assertion: line 1299 pos 12: '_focusedChildren.isEmpty || _focusedChildren.last.enclosingScope == this'

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

When the exception was thrown, this was the stack: 
#2      FocusScopeNode.focusedChild (package:flutter/src/widgets/focus_manager.dart:1299:12)
#3      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1384:17)
#4      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1400:18)
#5      FocusScopeNode.setFirstFocus (package:flutter/src/widgets/focus_manager.dart:1351:13)
#6      _ModalScopeState._routeSetState (package:flutter/src/widgets/routes.dart:1018:57)
#7      ModalRoute.setState (package:flutter/src/widgets/routes.dart:1177:31)
#8      ModalRoute.changedInternalState (package:flutter/src/widgets/routes.dart:1889:7)
#9      ModalRoute.didPopNext (package:flutter/src/widgets/routes.dart:1881:5)
#10     _RouteEntry.handleDidPopNext (package:flutter/src/widgets/navigator.dart:3032:11)
#11     NavigatorState._flushHistoryUpdates (package:flutter/src/widgets/navigator.dart:4259:19)
#12     NavigatorState.pop (package:flutter/src/widgets/navigator.dart:5291:7)
#13     Navigator.pop (package:flutter/src/widgets/navigator.dart:2570:27)
#14     AddItemMenu.build.<anonymous closure> (package:posnote/views/menu/add_item_menu.dart:225:23)
#15     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:344:24)
#16     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:652:11)
#17     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:309:5)
#18     BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:242:7)
#19     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:696:9)
#20     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
#21     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#22     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#23     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#24     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#25     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:495:19)
#26     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:475:22)
#27     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:425:11)
#28     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:420:7)
#29     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:383:5)
#30     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:330:7)
#31     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:299:9)
#32     _invoke1 (dart:ui/hooks.dart:328:13)
#33     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:442:7)
#34     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
(elided 2 frames from class _AssertionError)
Handler: "onTap"
Recognizer: TapGestureRecognizer#de0a1
  debugOwner: GestureDetector
  state: possible
  won arena
  finalPosition: Offset(180.0, 751.6)
  finalLocalPosition: Offset(180.0, 10.5)
  button: 1
  sent tap down
====================================================================================================

======== Exception caught by widgets library =======================================================
The following assertion was thrown building ListenableBuilder(listenable: ValueNotifier<bool>#f408e(false), state: _AnimatedState#12782):
Focused child does not have the same idea of its enclosing scope as the scope does.
'package:flutter/src/widgets/focus_manager.dart':
Failed assertion: line 1299 pos 12: '_focusedChildren.isEmpty || _focusedChildren.last.enclosingScope == this'

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

The relevant error-causing widget was: 
  MaterialApp MaterialApp:file:///C:/my/Project/posnote/lib/main.dart:68:12
When the exception was thrown, this was the stack: 
#2      FocusScopeNode.focusedChild (package:flutter/src/widgets/focus_manager.dart:1299:12)
#3      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1384:17)
#4      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1400:18)
#5      FocusScopeNode._doRequestFocus (package:flutter/src/widgets/focus_manager.dart:1400:18)
#6      FocusNode.unfocus (package:flutter/src/widgets/focus_manager.dart:929:15)
#7      FocusNode.canRequestFocus= (package:flutter/src/widgets/focus_manager.dart:531:9)
#8      _ModalScopeState.build.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter/src/widgets/routes.dart:1071:50)
#9      ListenableBuilder.build (package:flutter/src/widgets/transitions.dart:1127:48)
#10     _AnimatedState.build (package:flutter/src/widgets/transitions.dart:135:48)
#11     StatefulElement.build (package:flutter/src/widgets/framework.dart:5599:27)
#12     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5487:15)
#13     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5650:11)
#14     Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#15     StatefulElement.update (package:flutter/src/widgets/framework.dart:5673:5)
#16     Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#17     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6776:14)
#18     Element.updateChild (package:flutter/src/widgets/framework.dart:3827:15)
#19     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5512:16)
#20     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5650:11)
#21     Element.rebuild (package:flutter/src/widgets/framework.dart:5203:7)
#22     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2905:19)
#23     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1136:21)
#24     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:443:5)
#25     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1392:15)
#26     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1313:9)
#27     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1171:5)
#28     _invoke (dart:ui/hooks.dart:312:13)
#29     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:419:5)
#30     _drawFrame (dart:ui/hooks.dart:283:31)
(elided 2 frames from class _AssertionError)