admin管理员组文章数量:1386918
I'm using GoRouter in my Flutter application to handle routing. However, when I navigate to a specific todo item, the screen freezes, but the log messages print correctly, indicating that the route transition is happening.
When I replace GoRouter with Navigator, everything works fine and the screen does not freeze.
I’ve defined the routes using GoRouter as follows:
static GoRoute _categoryTodosRoute() {
return GoRoute(
path: ':categoryId/todos',
builder: (context, state) {
final cid = state.pathParameters['categoryId']!;
return _categoryTodosRouteBuilder(cid);
},
routes: [
GoRoute(
path: 'todo/:todoId',
builder: (context, state) {
final tid = state.pathParameters['todoId']!;
log('${tid}');
return TodoView();
},
),
],
);
}
The 'categoryId/todos' is accessed correctly with no errors. The problem is with the below route, 'todo/:todoId'.
The navigation is done like that:
case _TodoMenuAction.view:
context.go('/categories/${categoryModel.id}/todos/todo/${todoModel.id}');
break;
The log message prints correctly, but the screen freezes and nothing updates visually.
However, when I replace GoRouter with the Navigator method like so:
case _TodoMenuAction.view:
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TodoView()),
);
break;
The screen updates without issues.
本文标签: Flutter GoRouter causes screen freeze while Navigator works fineStack Overflow
版权声明:本文标题:Flutter GoRouter causes screen freeze while Navigator works fine - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744513991a2610047.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论