Last active
January 16, 2023 07:02
-
-
Save wilburx9/c5b522bdfc2fd8e79e58c60a93a173ab to your computer and use it in GitHub Desktop.
Revisions
-
Wilburt revised this gist
Oct 21, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,7 +49,7 @@ handleDismiss(DismissDirection direction, int index) { textColor: Colors.yellow, onPressed: () { // Deep copy the email final copiedEmail = Email.copy(swipedEmail); // Insert it at swiped position and set state items.insert(index, copiedEmail); // Also insert the item to the AnimatedList -
Wilburt created this gist
Oct 19, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ Tween<Offset> _offSetTween = Tween( begin: Offset(1, 0), end: Offset.zero, ); ... @override Widget build(BuildContext context) { return Scaffold( ... body: AnimatedList( key: _animatedListKey, initialItemCount: items.length, itemBuilder: (context, index, animation) { var item = items[index]; return FadeTransition( opacity: animation, child: SlideTransition( position: _offSetTween.animate(animation), child: Dismissible( ... ), ), ); }, ), ); } handleDismiss(DismissDirection direction, int index) { ... // Remove it from the list items.removeAt(index); // Remove it from the animated list _animatedListKey.currentState.removeItem( index, (context, animation) { return SizedBox(); }, ... _scaffoldKey.currentState .showSnackBar( SnackBar( ... action: SnackBarAction( label: "Undo", textColor: Colors.yellow, onPressed: () { // Deep copy the email final copiedEmail = Email.from(swipedEmail); // Insert it at swiped position and set state items.insert(index, copiedEmail); // Also insert the item to the AnimatedList _animatedListKey.currentState.insertItem(index); }), ), ) ... }