jushutch / swiping_card_deck

A widget for swiping through a deck of cards with gestures or buttons.
https://pub.dev/packages/swiping_card_deck
BSD 3-Clause "New" or "Revised" License
13 stars 10 forks source link

Added saving swipeController between recreating widget #17

Closed ihorbokov closed 2 years ago

ihorbokov commented 2 years ago

There is a problem when SwipingGestureDetector widget recreating and in this time late final AnimationController swipeController; is lost because void initState() is called only one time.

jushutch commented 2 years ago

This PR looks great, thank you for contributing! Before I merge the PR, do you have steps to recreate the original issue? I'd like to write a regression test for this issue if possible.

ihorbokov commented 2 years ago

Sure, for recreate the original issue you can use your example from pub.dev, after you've compiled the example try to swipe a few cards and go ahead and do 'hot restart' and after this swipe a card again, in this case you should see this error - Unhandled Exception: LateInitializationError: Field 'swipeController' has not been initialized..

jushutch commented 2 years ago

I was able to recreate the original issue and your solution works great, thank you again for contributing! 🎉