【发布时间】:2021-11-13 14:00:51
【问题描述】:
我正在为 web 使用颤振。
页面正在以Navigator.of(context).pushNamed(Home.route); 转换,但此时播放动画。
是否可以禁用此动画?
我在main.dart的main()函数中写了如下代码。
MaterialApp(
initialRoute: '/home',
routes: {
'/home': (context) => Home(),
'/profile': (context) => Profile(),
},
@immutable
class Home extends StatelessWidget {
static const String route = '/home';
....
}
@immutable
class Profile extends StatelessWidget {
static const String route = '/profile';
....
}
正如我之前提到的,以下代码用于转换页面。
Navigator.of(context).pushNamed(Home.route);
我可以使用Navigator.push 转换没有动画的页面,但我想使用Navigator.of(context).pushNamed(),因为链接不会改变。
有谁知道如何在使用Navigator.of(context).pushNamed() 的同时禁用动画?
谢谢。
【问题讨论】:
标签: flutter dart flutter-web