小编Mar*_*sky的帖子

在 Flutter 中设置 go_router 的默认转换

正如go_router 的文档所描述的,为单个页面设置pageBuilder-Transitions 很容易。但是,我想为所有页面设置默认的 PageTransition。

如何在 Flutter 中使用 go_router 设置默认页面转换?

单页:


  // this is the proposed method to do it for single pages
  // how can i apply it to all pages without writing the same code?
  GoRoute(
      path: '/login',
      builder: (context, state) => const LoginScreen(),
      pageBuilder: (context, state) => CustomTransitionPage<void>(
        key: state.pageKey,
        child: const LoginScreen(),
        transitionsBuilder: (context, animation, secondaryAnimation, child) =>
            FadeTransition(opacity: animation, child: child),
      ),
    ),
Run Code Online (Sandbox Code Playgroud)

此致

navigation animation transition flutter gorouter

16
推荐指数
4
解决办法
2万
查看次数

标签 统计

animation ×1

flutter ×1

gorouter ×1

navigation ×1

transition ×1