Flutter 页面路由动画

时间:2021-01-08 14:59:46

标签: flutter flutter-layout flutter-animation

如何为现有路线添加动画?

 child: MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Home',
        home: Home(),
        onGenerateInitialRoutes: ,
        routes: {
          SettingsScreen.routeName: (ctx) => SettingsScreen(),
          AboutScreen.routeName: (ctx) => AboutScreen(),
        },

从我目前的搜索来看,看起来我必须实现 onGenerateRoute

这是否意味着我必须删除当前的路线设置?

1 个答案:

答案 0 :(得分:0)

在此处查看官方文档:https://api.flutter.dev/flutter/material/PageTransitionsTheme-class.html

示例用法:

return MaterialApp(
  title: 'Transitions Page',
  theme: ThemeData(
      pageTransitionsTheme: PageTransitionsTheme(builders: {
    TargetPlatform.iOS: ZoomPageTransitionsBuilder(),
    TargetPlatform.android: CupertinoPageTransitionsBuilder(),
  })),
  home: MyHomePage(title: 'Some page'),
);