如何解决Flutter导航器推送过渡未显示
一旦尝试处理Firebase身份验证用户,我将尝试制作一个具有淡入淡出动画的初始屏幕。这是我目前的代码:
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
auth.onAuthStateChanged.listen((user) async {
if (user == null) {
if (ModalRoute.of(context).isCurrent) {
Navigator.pushNamed(context,'/welcome');
} else {
Navigator.popUntil(context,ModalRoute.withName('/welcome'));
}
} else {
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (BuildContext context,Animation<double> animation1,Animation<double> animation2) {
return NavigationHomeScreen();
},transitionsBuilder: (BuildContext context,Animation<double> animation,Animation<double> animation2,Widget child) {
return FadeTransition(
opacity: animation,child: child
);
},),);
}
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Image.asset(
'assets/icons/app_logo_transparent.png',width: MediaQuery.of(context).size.width*0.4,);
}
}
由于某种原因,动画从不显示,并且屏幕仅从启动屏幕突然切换到主屏幕。我已经验证了此动画可以在所有其他实例中使用,但是在此listen方法中却不起作用。另外,如果我从主屏幕弹出回到初始屏幕,则动画效果很好。当我按到主屏幕时,它只是不显示。有人知道如何解决这个问题吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。