Skip to content

support Dismissible Widget #136

@Hilbert2048

Description

@Hilbert2048

example code: just add Dismissible Widget in the main.dart of example project
issue
1、if I use the onDismissed callback, it will always hit the exception: A dismissed Dismissible widget is still part of the tree.
Make sure to implement the onDismissed handler and to immediately remove the Dismissible widget from the application once that handler has fired.
2、if I use the confirmDismiss callback to setState, the re-layout animation is strange...

example code:

  ? AnimatedReorderableGridView(
                        items: list,
                        itemBuilder: (BuildContext context, int index) {
                          final user = list[index];
                          return Dismissible(
                              key: ValueKey(user.id),
                              confirmDismiss: (direction) async {
                                setState(() {
                                  list.removeAt(index);
                                });
                                return true;
                              },
                              onDismissed: (DismissDirection direction) {
                                // setState(() {
                                //   list.removeAt(index);
                                // });
                              },
                              child: ItemCard(
                                key: ValueKey('${user.id}_item'),
                                id: user.id,
                                dragEnabled: !nonDraggableItems.contains(user),
                                isLocked: lockedItems.contains(user),
                              ));
                        },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions