栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

更改BLoC模式上的Widget时如何添加动画过渡?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

更改BLoC模式上的Widget时如何添加动画过渡?

您可以使用AnimatedSwitcher包装页面:

return BlocProvider<AuthenticationBloc>(  bloc: authenticationBloc,  child: MaterialApp(    home: BlocBuilder<AuthenticationEvent, AuthenticationState>(      bloc: authenticationBloc,      builder: (BuildContext context, AuthState state) {        return AnimatedSwitcher(          duration: Duration(milliseconds: 250),          child: _buildPage(context, state),        );      },    ),  ),);

默认情况下,它使用淡入淡出过渡,并以相反的顺序为旧的和新的小部件设置动画。


要在动画过程中将旧窗口小部件保留在适当的位置,请传递给AnimatedSwitcher

switchOutCurve: Threshold(0),

要模拟

Navigator.push
Android中的过渡,请将其传递给它

transitionBuilder: (Widget child, Animation<double> animation) {  return SlideTransition(    position: Tween<Offset>(      begin: const Offset(0, 0.25),      end: Offset.zero,    ).animate(animation),    child: child,  );},

要使用系统转换,请尝试类似

transitionBuilder: (Widget child, Animation<double> animation) {  final theme = Theme.of(context).pageTransitionsTheme;  final prev = MaterialPageRoute(builder: (_) => widget);  return theme.buildTransitions(prev, context, animation, null, child);},

(最后一个测试得不好)



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/384050.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号