Flutter go_router库push导航后,浏览器地址栏的地址不更新的问题
如果你使用.push()
方法进行导航后,浏览器的地址栏的地址并没有更新,那是因为go_router经过了一次变更修改行为导致的。
配置下边的GoRouter.optionURLReflectsImperativeAPIs = true;
代码就行了。
也可以去optionURLReflectsImperativeAPIs看属性说明。
原文
关于如何查看路由栈的列表,参考
final GoRouter goRouter = createRouter();
// TODO: routeExists implementation is a workaround to known issue: https://github.com/flutter/flutter/issues/117514
bool routeExists(String route) {
try {
return goRouter.routeInformationParser.configuration.findMatch(route).matches.isNotEmpty;
} catch (err) {
return false;
}
}
https://github.com/flutter/flutter/issues/157840
https://github.com/flutter/flutter/issues/117514
复制请注明出处,在世界中挣扎的灰太狼