gpt4 book ai didi

flutter - 如何在我的 Flutter 应用程序中向我的 Flutter 路由添加自定义转换

转载 作者:IT老高 更新时间:2023-10-28 12:32:15 35 4
gpt4 key购买 nike

如何向我的 Flutter 路由添加自定义转换?这是我目前的路线结构。

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Yaip',
theme: new ThemeData(
primarySwatch: Colors.pink,
brightness: Brightness.light
),
home: new VerifyPhoneNumber(),
routes: <String, WidgetBuilder>{
'/verified': (BuildContext context) => new MobileNumberVerified(),
'/setupprofile': (BuildContext context) => new SetUpProfile()
},
);
}
}

最佳答案

使用PageRouteBuilder:

Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (_, __, ___) => Page2(),
transitionsBuilder: (_, a, __, c) => FadeTransition(opacity: a, child: c),
transitionDuration: Duration(milliseconds: 2000),
),
);

关于flutter - 如何在我的 Flutter 应用程序中向我的 Flutter 路由添加自定义转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46062422/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com