flutter - 如何为 Flutter SliverList 中的元素设置动画?
问题描述
当用户滚动列表时,我有一个SliverList
与 aSliverAppBar
一起使用的动画应用栏(标准用例的条子真的,没什么特别的)。
现在我想为SliverList
. 例如,添加项目时的水平滑动过渡,或重新排序列表时元素之间的一种垂直“随机播放”。提供了其中AnimatedList
一些功能,但不提供 SliverList。
我对框架的理解是,可以将提供给框架的元素包装SliverList
在一个AnimatedWidget
(或一些类似的小部件)内以动画化更改。但是我对 Flutter 动画的了解还是有点太新鲜了,所以我在寻求帮助。
这是我的代码的一部分。我想为GameScoreWidget
下面的实例制作动画。
SliverList(
delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
if (index == 0) {
return ListReorderWidget(viewModel: viewModel);
}
else if (!viewModel.isLatestGame(index-1)) {
return GameScoreWidget(position: index-1, viewModel: viewModel);
}
else
return Dismissible(
direction: DismissDirection.endToStart,
child: GameScoreWidget(position: index-1, viewModel: viewModel),
key: UniqueKey(),
background: Container(color: Colors.red),
onDismissed: (direction) {
onGameDismissed(context);
},
);
},
childCount: viewModel.games.length+1,
),
)
我找不到任何与我的问题相关的答案。我发现这个问题与SliverList 中的动画变化有关
但是没有答案...
解决方案
推荐阅读
- html - 如何从Angular CLI中来自ManyToOne关系的对象中获取值?
- java - Android 单元测试:模拟上下文也返回一个循环器
- python - 年龄范围到年龄数值(python)
- php - 使用反斜杠访问对象属性
- android - 当应用程序在后台时,Android altbeacon 的间隔范围
- r - 值在加载到 R 时被转换
- python - 如何将旧的 python 2.7.x 版本升级到 2.7.16?
- oauth-2.0 - 使用 Azure AD 正确授权策略以保护 CLI 到 REST API
- python - Scipy 优化器在改变指定参数的方式时爆炸/发散
- javascript - 使用 c# 创建 WebAssembly