颤动:ListView中的动画项目删除

颤动:ListView中的动画项目删除,第1张

概述我正在从Stream构建ListView.我需要为该列表添加删除和插入动画,但不知道如何. 我已经看过Flutter的这个示例,但它与流无关:https://flutter.io/catalog/samples/animated-list/ 任何帮助非常感谢:) new StreamBuilder( stream: feed.stream, // this is a Stream<Lis 我正在从Stream构建ListVIEw.我需要为该列表添加删除和插入动画,但不知道如何.

我已经看过Flutter的这个示例,但它与流无关:https://flutter.io/catalog/samples/animated-list/

任何帮助非常感谢:)

new StreamBuilder(    stream: Feed.stream,// this is a Stream<List<Product>>    builder: (context,snapshot) {      if (!snapshot.hasData)        return const Text('Loading products');      return new ListVIEw.builder(          itemCount: snapshot.data.length,itemBuilder: (context,index) {            Product product = snapshot.data[index];            return new ProductWidget(product);          });    });
解决方法 这不是使用Streams,但作为AnimatedList的一般答案,您可以执行以下 *** 作:

// Remove "Pig" from the Listint removeIndex = 2;// remove the item from the data List backing the AnimatedListString removedItem = _data.removeAt(removeIndex);// This builder is just so that the animation has something// to work with before it disappears from vIEw since the original// has already been deleted.AnimatedListRemovedItemBuilder builder = (context,animation) {  // A method to build the Card Widget.  return _buildItem(removedItem,animation);};// notify the AnimatedList that the item was removed_ListKey.currentState.removeItem(removeIndex,builder);
总结

以上是内存溢出为你收集整理的颤动:ListView中的动画项目删除全部内容,希望文章能够帮你解决颤动:ListView中的动画项目删除所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1000462.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存