�� reorderable grid ��
a full reorderable grid implemention similar to flutters reorderable_list. withfull reorderablegridview
, reorderablegrid
and sliverreorderablegrid
implementations
�� how it works
reorderablegridview
is a drop in replacement for the existing gridview
and adds an onreorder
callback that provides the original and new index of the reordered item.
/// create a new list of data
final items = list<int>.generate(40, (index) => index);
/// when the reorder completes remove the list entry from its old position
/// and insert it at its new index
void _onreorder(int oldindex, int newindex) {
setstate(() {
final item = items.removeat(oldindex);
items.insert(newindex, item);
});
}
@override
widget build(buildcontext context) {
return materialapp(
home: scaffold(
body: reorderablegridview.extent(
maxcrossaxisextent: 250,
onreorder: _onreorder,
childaspectratio: 1,
children: items.map((item) {
/// map every list entry to a widget and assure every child has a
/// unique key
return card(
key: valuekey(item),
child: center(
child: text(item.tostring()),
),
);
}).tolist(),
),
),
);
}
reorderablegrid
provides all the constructors and parameters the normal gridview
has. the package also includes:
reorderablegridview
, which is a prebuild material-ish implementation of the grid.reorderablegrid
, a barebones widget that allows you to customize the grid however you wantsliverreorderablegrid
, a reorderable grid sliver for custom scroll implementations
�� get involved
if this package is useful to you please �� on pub.dev and ⭐ on . if you have any issues, recommendations or pull requests i’d love to see them!
Comments are closed.