最近遇到个需求,要求在一个 ListView 里面能互换两个 item 的位置,这样:
于是,就有了现在的这个 WReorderList
。
WReorderList
功能就不用多说了,可以随意替换两个 item 的位置。
构造函数及其用法
还是按照老规矩,先来看一下构造函数:
WReorderList({
Key key,
@required this.children,
@required this.onIndexChanged,
this.duration = const Duration(milliseconds: 500)
}) : super(key: key);
一共四个参数:
1.key:不用多说2.children:子组件集合3.onIndexChanged:当两个位置变化之后的回调,要更改您自己的数据源4.duration:动画时间
怎么用就很简单了: