reorderable_grid_view 0.0.1 copy "reorderable_grid_view: ^0.0.1" to clipboard
reorderable_grid_view: ^0.0.1 copied to clipboard

outdated

Reorderable Grid View

ReorderableGrdiView #

Copy from official ReorderableListView

Usage: #

dependencies:
  reorderable_list_view: 0.0.1

Example #

class _MyHomePageState extends State<MyHomePage> {
  final data = [1, 2, 3, 4, 5];

  @override
  Widget build(BuildContext context) {
    Widget buildItem(String text) {
      return Card(
        key: ValueKey(text),
        child: Text(text),
      );
    }

    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: ReorderableGridView(
          crossAxisSpacing: 10,
          mainAxisSpacing: 10,
          crossAxisCount: 3,
          children: this.data.map((e) => buildItem("$e")).toList(),
          onReorder: (oldIndex, newIndex) {
            setState(() {
              final element = data.removeAt(oldIndex);
              data.insert(newIndex, element);
            });
          },
          footer: [
            Card(
              child: Center(
                child: Icon(Icons.add),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Note #

I don't know how to calculate the child's size and the gap size. So when there's crossAxisSpacing or mainAxisSpacing. The position has deviation.

If you know how to do it, please teach me.

154
likes
0
pub points
97%
popularity

Publisher

unverified uploader

Reorderable Grid View

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on reorderable_grid_view