如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),
),
),
最好的问候
transitionBuilder
的调用中,animation
和secondaryAnimation
对象来自哪里? - yurin