Flutter:可重新排序且具有动画效果的ListView-有什么想法吗? [英] Flutter: Reorderable AND Animated ListView - any idea?

查看:151
本文介绍了Flutter:可重新排序且具有动画效果的ListView-有什么想法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Flutter对ListViews使用不同的方法:

  • ListView

  • AnimatedList

  • ReorderableListView

但是还有可能组合所有不同的功能吗?

我需要一个ReorderableListView,以通过拖放操作对商品进行重新排序;同时可以添加和删除带有动画的项目.

我错过了什么吗?还是没有这样的东西?尝试工作了好几个小时.

任何变通方法也将受到赞赏.

解决方案

我还需要一个可以结合所有这些功能的 ListView ,并且由于找不到,我决定通过以下方式创建一个我自己称为 implicitly_animated_reorderable_list ,可以在这里找到:

请注意,这个软件包还很年轻,我在业余时间开发了它,也就是说,它还不应该被认为已经可以投入生产.

I get that Flutter has different approaches for ListViews:

  • ListView

  • AnimatedList

  • ReorderableListView

But is there also a possibility to combine all different functions?

I need a ReorderableListView to reorder items via drag & drop while being able to add and remove items with animations.

Am I missing something or is there no such thing? Trying things for hours alredy..

Any workarounds are also appreciated.

解决方案

I also needed a ListView that could combine all of these functionalities and because I couldn't find one I decided to create one by myself which is called implicitly_animated_reorderable_list and can be found here:

https://pub.dev/packages/implicitly_animated_reorderable_list

The package contains two ListViews: ImplicitlyAnimatedList which is based on AnimatedList and uses a diff algorithm (MyersDiff) to calculate the changes between two lists and automatically (or "implicitly") animates between them for. So you don't have two call insertItem or removeItem on the AnimatedListState manually anymore. Then theres ImplicitlyAnimatedReorderableList which extends this functionality and adds support to reorder its items.

For examples on how to use them please refer to the readme and the example application in the repository as this would be to long for a single answer.

Here is an example what it looks like (I had to compress it a bit as the max file size is 2mb):

Note that this package is still very young and I developed it in my spare time which is to say that it should not be considered production ready (yet).

这篇关于Flutter:可重新排序且具有动画效果的ListView-有什么想法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆