Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

生命周期监听器RouteAware无法监听 #1522

Closed
Keanyuan opened this issue Dec 17, 2021 · 5 comments
Closed

生命周期监听器RouteAware无法监听 #1522

Keanyuan opened this issue Dec 17, 2021 · 5 comments

Comments

@Keanyuan
Copy link

版本:v3.0-preview.16

在使用flutter boost时发现在flutterContainer容器中通过Navigator.push(context, MaterialPageRoute(builder: (_) => child))方式跳转的页面
A 页面----Navigator.push--->B页面
现象:
GlobalPageVisibilityObserver 无法监听到onPagePush

B页面 --Navigator.pop-> A页面
现象:
GlobalPageVisibilityObserver 无法监听到onPagePop

在A页面自定义RouteAware进行监听
现象:
didPush可以触发
A 页面----Navigator.push--->B页面
didPushNext 无法监听到
B页面 --Navigator.pop-> A页面
didPopNext无法监听到

请问这种情况我该如何处理????

@xujinping
Copy link
Collaborator

@Keanyuan 你在使用原生 Navigator.push路由的时候,给路由带一个参数 settings 即可,代码如下

Navigator.push(context, MaterialPageRoute(
settings: RouteSettings(name:"youer routeName"),
builder: (_) => child))

@Keanyuan
Copy link
Author

Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 4564 pos 12: '!_debugLocked': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2 NavigatorState._pushEntry (package:flutter/src/widgets/navigator.dart:4564:12)
#3 NavigatorState.push (package:flutter/src/widgets/navigator.dart:4480:5)
#4 Navigator.push (package:flutter/src/widgets/navigator.dart:2130:34)
#5 NavigatorUtils._push (package:flutter_crm_moudle/util/navigator_utils.dart:78:22)
#6 NavigatorUtils.pushTO (package:flutter_crm_moudle/util/navigator_utils.dart:39:12)
#7 _CustomerDetailMiddlePageState.build. (package:flutter_crm_moudle/page/CustomerDetail/customer_detail_middle_page.dart:319:50)
#8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#9 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:607:11)
#10 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:296:5)
#11 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:267:7)
#12 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
#13 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:443:20)
#14 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:419:22)
#15 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:287:11)
#16 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
#17 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
#18 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296:7)
#19 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279:7)
#20 _rootRunUnary (dart:async/zone.dart:1370:13)
#21 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#22 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#23 _invoke1 (dart:ui/hooks.dart:182:10)
#24 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:282:7)
#25 _dispatchPointerDataPacket (dart:ui/hooks.dart:96:31)

@Keanyuan
Copy link
Author

@xujinping
RouteSettings 会报错 无法跳转

@xujinping
Copy link
Collaborator

从日志看错误和本问题没啥关联,检查下代码吧

@Keanyuan
Copy link
Author

感谢问题解决 attach 重新reload可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants