Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dismissible and implicitly_animated_reorderable_list #21

Open
giorgio79 opened this issue Jun 4, 2023 · 4 comments
Open

Dismissible and implicitly_animated_reorderable_list #21

giorgio79 opened this issue Jun 4, 2023 · 4 comments

Comments

@giorgio79
Copy link

giorgio79 commented Jun 4, 2023

Just tried wrapping the Animated Item in Dismissible, but getting an error https://stackoverflow.com/questions/55792521/how-to-fix-a-dismissed-dismissible-widget-is-still-part-of-the-tree-error-in

will try to get a full example going...

PS It looks like the animation is carried out twice, once by Dismissible, and then by Implicitly_animated_reorderable_list. Perhaps need to override somehow the removedItemBuilder to avoid animation if Dismissible was used...

PS2 Looks like the example uses the Flutter Slideable package. Gonna check it out. https://github.com/wwwdata/implicitly_animated_reorderable_list/blob/479c09211e5b02093e294ca7c573f98f43c62124/example/lib/ui/lang_page.dart

itemBuilder: (context, animation, item, index) {
// Specifiy a transition to be used by the ImplicitlyAnimatedList.
// See the Transitions section on how to import this transition.
return Dismissible(
...
child: SizeFadeTransition(
sizeFraction: 0.7,
curve: Curves.easeInOut,
animation: animation,
child: Text(item.name),
);
},

@giorgio79
Copy link
Author

Found a nice solution here that explains how to use Dismissible with Animated List https://morthor.medium.com/flutter-animatedlist-sizetransition-dismissible-dce49c11200d

void removeItem(String item, int index){ animatedListKey .currentState .removeItem(index, (context, animation) { return SizedBox(width: 0, height: 0); }); list. Remove(item); }

We will use the removeItem method from our AnimatedList, using its key, to make sure the item is removed from it, but because we are using the Dismissible Widget’s animation, we will only return an invisible, empty box. A SizedBox Widget with Zero height and width. This ensures that there is no interference.

@wwwdata
Copy link
Owner

wwwdata commented Jun 5, 2023

yes, Dismissible is running its own animation when the user slides the item to remove it. So you need to disable the removal animation in that case from the animated list

@giorgio79
Copy link
Author

Thx Ben, yeah I got it working via a regular Animated List, but still saw a flicker with Animated_List_Plus unfortunately. Dont know if animatedListKey solution also works with Animated_List_Plus

@cachapa
Copy link

cachapa commented Aug 22, 2023

I adapted from the above solution by temporarily storing the id of the item being deleted, and in the list.build method if the item matches, then it just returns an empty SizedBox while the Dismissible does its thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants