animated_reorderable library

A Flutter library that provides animating, reordering, and swiping capabilities for both ListView and GridView. This library enhances the user experience by allowing seamless and visually appealing interactions with list or grid items.

Features:

  • Animates item insertions, removals, and reordering with customizable animations.
  • Allows users to interactively reorder items with drag-and-drop gestures.
  • Swipe-to-remove functionality for removing items with animated effects.
  • Configurable decorators for the dragged and swiped items.
  • Callbacks for tracking item drag and swipe events.

Usage:

To use this library, import it into your Flutter project and wrap your ListView or GridView with the AnimatedReorderable widget.

Example:

import 'package:animated_reorderable/animated_reorderable.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const Example());
}

class Example extends MaterialApp {
  const Example({super.key})
      : super(
          home: const Scaffold(
            body: ListViewExample(),
          ),
        );
}

class ListViewExample extends StatefulWidget {
  const ListViewExample({super.key});

  @override
  State<ListViewExample> createState() => _ListViewExampleState();
}

class _ListViewExampleState extends State<ListViewExample> {
  final items = [1, 2, 3, 4, 5];

  @override
  Widget build(BuildContext context) {
    return AnimatedReorderable.list(
      keyGetter: (index) => ValueKey(items[index]),
      onReorder: (permutations) => permutations.apply(items),
      listView: ListView.builder(
        itemCount: items.length,
        itemBuilder: (context, index) => Card(
          child: Padding(
            padding: const EdgeInsets.all(16),
            child: Text('Item: ${items[index]}'),
          ),
        ),
      ),
    );
  }
}

Classes

AnimatedReorderable
The AnimatedReorderable wrapper makes ListView or GridView animated, adds reordering and swiping capabilities.
AnimatedReorderableState<T extends AnimatedReorderable>
The AnimatedReorderableState for AnimatedReorderable, a wrapper for list or grid that animates items when they are inserted, removed or reordered.
Permutation
A class that represents a single permutation (reordering) of an item.
Permutations
A class representing permutations of items in a list.

Typedefs

AxisDirectionGetter = AxisDirection? Function(int index)
A function that determines the axis direction associated with an item at a given index.
BoolGetter = bool Function(int index)
A function signature to get the bool property of the item at the specified index.
ItemDragEndCallback = void Function(DragEndDetails details, int index)
A callback function that is called when dragging of an item ends.
ItemDragStartCallback = void Function(DragStartDetails details, int index)
A callback function that is called when dragging of an item starts.
ItemDragUpdateCallback = void Function(DragUpdateDetails details, int index)
A callback function that is called when dragging of an item is updated.
KeyGetter = Key Function(int index)
A function utilized by AnimatedReorderable to obtain the unique key for the item at the specified index within the list or grid.
MultiDragGestureRecognizerFactory = MultiDragGestureRecognizer Function(BuildContext context)
A factory function that creates a MultiDragGestureRecognizer for handling drag gestures
ReorderCallback = void Function(Permutations permutations)
A callback function that is called when the items are reordered.
SwipeToRemoveCallback = void Function(int index)
A callback function that is called when an item is swiped for removal.