颤音:使Splash屏幕加载所有API的数据
我有Flutter应用程序需要将一些API的数据加载到包含动画的飞溅屏幕中。
class _SplashPageState extends State<SplashPage> {
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
var auth = Provider.of<AuthProvider>(context, listen: false);
auth.chekingAuthVariables();
var loading = Provider.of<LoadingProvider>(context, listen: false);
loading.getBrands();
loading.getVideos();
var catsProv = Provider.of<CatProviders>(context, listen: false);
catsProv.getCategoryList();
});
super.initState();
}
@override
Widget build(BuildContext context) {
return AnimatedSplashScreen(
backgroundColor: ColorManager.tabBottonNonActive,
duration: 3000,
splash: 'assets/splash.png',
nextScreen: const MainTabPage(),
splashTransition: SplashTransition.slideTransition,
);
}
}
动画的持续时间为3秒钟,有时当网络慢速时,API的数据不加载,这是加载某些屏幕的问题。 加载所有API的数据后,如何使动画持续时间完成?
I have flutter app need to load some api's data in splash screen which contain animation.
class _SplashPageState extends State<SplashPage> {
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
var auth = Provider.of<AuthProvider>(context, listen: false);
auth.chekingAuthVariables();
var loading = Provider.of<LoadingProvider>(context, listen: false);
loading.getBrands();
loading.getVideos();
var catsProv = Provider.of<CatProviders>(context, listen: false);
catsProv.getCategoryList();
});
super.initState();
}
@override
Widget build(BuildContext context) {
return AnimatedSplashScreen(
backgroundColor: ColorManager.tabBottonNonActive,
duration: 3000,
splash: 'assets/splash.png',
nextScreen: const MainTabPage(),
splashTransition: SplashTransition.slideTransition,
);
}
}
the duration of animation is 3 seconds, sometimes when the net is slow the api's data dont load which make a problem for loading some screens.
How can I make the duration of animation finish after loading all api's data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我注意到您正在不使用
等待
的情况下进行API调用,考虑到您正在从异步来源加载数据,这很奇怪。I noticed you are making API calls without using
await
, which is quite odd considering you are loading data from an asynchronous source.