mcrovero / rubber

An elastic material bottom sheet implementation for Flutter.
BSD 2-Clause "Simplified" License
562 stars 88 forks source link

Fixed bugs in AnimationController.launchTo() #10

Closed aryzhov closed 5 years ago

aryzhov commented 5 years ago

I noticed a bug: when I call:

   bottomSheetController.launchTo(AnimationState.collapsed);

The bottom sheet disappears, but then appears again in 20 seconds. That's weird. After some debugging, I found that the animation that's supposed to collapse the bottom sheet, never ends, and _value gets set to 1.0 suddenly after 20 seconds. Further debugging revealed that the root cause was the direction that was set incorrectly to 1.0 whereas it should be -1.0 in case of collapsing the popup. In fact, by looking at animation_controller.dart:361 it's obvious that direction will always be equal to 1.0. After my fix, everything started working well and the animation stops when it should.

While reviewing my changes, I noticed that the code might also not be handling correctly the case where targetBound == currentBound. Indeed, that results in a never-ending animation as well. I fixed that in launch().

mcrovero commented 5 years ago

Great job! Hopefully I've time to publish the next release with all these bug fix in the next days