颤振:在ListView中设置项目移除动画

颤振:在ListView中设置项目移除动画,listview,dart,flutter,Listview,Dart,Flutter,我正在从流构建ListView。我需要动画删除和插入到该列表,但不知道如何 我通过颤振看到了该样本,但它与溪流没有任何关系: 非常感谢您的帮助:) 新建StreamBuilder( stream:feed.stream,//这是一个流 生成器:(上下文,快照){ 如果(!snapshot.hasData) 返回常量文本(“加载产品”); 返回新的ListView.builder( itemCount:snapshot.data.length, itemBuilder:(上下文,索引){ 产品=快

我正在从流构建ListView。我需要动画删除和插入到该列表,但不知道如何

我通过颤振看到了该样本,但它与溪流没有任何关系:

非常感谢您的帮助:)

新建StreamBuilder(
stream:feed.stream,//这是一个流
生成器:(上下文,快照){
如果(!snapshot.hasData)
返回常量文本(“加载产品”);
返回新的ListView.builder(
itemCount:snapshot.data.length,
itemBuilder:(上下文,索引){
产品=快照.数据[索引];
返回新的ProductWidget(产品);
});
});

作为动画列表的一般答案,您可以执行以下操作:


您是否尝试过“可驳回”?您能提供完整的示例吗?“这对我会很有帮助的。”帕特汉德里,我有一个更完整的帖子。它在结尾包含了完整的代码。我在你的例子中看到你使用了animatedlist,但在我的例子中我使用了reorderable 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);
          });
    });
// Remove "Pig" from the list
int removeIndex = 2;

// remove the item from the data list backing the AnimatedList
String 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);