最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Flutter GoRouter causes screen freeze while Navigator works fine - Stack Overflow

programmeradmin4浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论