考虑两条路线,A和B。从A导航到B后,如何使B中的小部件逐渐淡入(从不透明度0到1)?
似乎您正在寻找的是具有自定义过渡的PageRouteBuilder,如下所示:
return Navigator.of(context).push(PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) {
return HomePage();
},
transitionDuration: Duration(milliseconds: 500),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
return FadeTransition(
opacity: animation,
child: child,
);
}
));