rubber
rubber copied to clipboard
Flag to make sheet to not overflow its lower and upper bounds (strictier controller values range)
I faced a need to keep sheet strictly in its bounds, so, when I didn't find any out-of-box solution, I decided to play with it by myself. And what I got:
In _onVerticalDragUpdate
function from RubberBottomSheet
I replaced one line like this
//_controller.value -= details.primaryDelta / screenHeight * friction;
var newValue = controller.value - (details.primaryDelta / _screenHeight * friction);
if (_someFlagThatMakesControllerBeAwareAboutSheetBounds) {
if (newValue > controller.upperBound)
newValue = controller.upperBound;
else if (newValue < controller.lowerBound)
newValue = controller.lowerBound;
}
controller.value = newValue;
And after some gestures that caused fling
of RubberAnimationController
to be called, sheet comes collapsed or even disappears. But I played with it too and added these lines before simulation object creates (because it caused division by zero inside) [Not sure if it's necessary after update edits, couldn't catch it again]
if (value == to)
return null;
Upd:
Also, controller should have added (_tick
), right before notifyListeners()
:
// Strict boundaries enforced
if(_someFlagThatMakesControllerBeAwareAboutSheetBounds && _value > upperBound)
_value = upperBound;
So I hope it will appear in Rubber in a future.
+1