flutter_boost 项目中原来的Navigator的pushAndRemoveUntil或pushReplacement方法调用失败

u5i3ibmn  于 2022-11-19  发布在  Flutter
关注(0)|答案(1)|浏览(248)

调用Navigator.pushAndRemoveUntil或Navigator.pushReplacement时,这两处断言会失败。虽然有BoostNavigator.pushReplacement方法,但是改造成本比较大。且,没有BoostNavigator.pushAndRemoveUntil方法,无法进行清栈处理。怎么解?
boost:4.0.4(前几个版本应该也差不多的情况)
flutter:3.3.1(前几个版本应该也差不多的情况)

// Route is removed without being completed.
void remove({ bool isReplaced = false }) {
assert(
!hasPage || isWaitingForExitingDecision,
'A page-based route cannot be completed using imperative api, provide a '
'new list without the corresponding Page to Navigator.pages instead. ',
);
......
}

// Route completes with result and is removed.
void complete(T result, { bool isReplaced = false }) {
assert(
!hasPage || isWaitingForExitingDecision,
'A page-based route cannot be completed using imperative api, provide a '
'new list without the corresponding Page to Navigator.pages instead. ',
);
......
}

据排查,发现当前页面是BoostPage时,hasPage==true,所以断言失败

kpbpu008

kpbpu0081#

谢谢反馈,请问可以在flutterboost的example里提供一个可复现的demo吗?

相关问题