Unverified Commit 8469896c authored by xubaolin's avatar xubaolin Committed by GitHub

Fix DDS do not support Curves.easeInOutBack curve (#114222)

parent cdbb1e60
......@@ -136,13 +136,12 @@ class DraggableScrollableController extends ChangeNotifier {
animationController.value,
_attachedController!.position.context.notificationContext!,
);
if (animationController.value > _attachedController!.extent.maxSize ||
animationController.value < _attachedController!.extent.minSize) {
// Animation hit the max or min size, stop animating.
animationController.stop(canceled: false);
}
});
await animationController.animateTo(size, duration: duration, curve: curve);
await animationController.animateTo(
clampDouble(size, _attachedController!.extent.minSize, _attachedController!.extent.maxSize),
duration: duration,
curve: curve,
);
}
/// Jumps the attached sheet from its current size to the given [size], a
......@@ -579,7 +578,11 @@ class _DraggableSheetExtent {
/// or a user drag.
void updateSize(double newSize, BuildContext context) {
assert(newSize != null);
_currentSize.value = clampDouble(newSize, minSize, maxSize);
final double clampedSize = clampDouble(newSize, minSize, maxSize);
if (_currentSize.value == clampedSize) {
return;
}
_currentSize.value = clampedSize;
DraggableScrollableNotification(
minExtent: minSize,
maxExtent: maxSize,
......
......@@ -950,9 +950,7 @@ void main() {
goTo(.5);
await tester.pumpAndSettle();
goTo(0);
// The animation was cut short by half, there should have been on less pumps
final int truncatedPumpCount = shouldAnimate ? expectedPumpCount - 1 : expectedPumpCount;
expect(await tester.pumpAndSettle(), truncatedPumpCount);
expect(await tester.pumpAndSettle(), expectedPumpCount);
expect(
tester.getSize(find.byKey(containerKey)).height / screenHeight,
closeTo(.25, precisionErrorTolerance),
......@@ -1007,6 +1005,29 @@ void main() {
);
});
testWidgets('Can animateTo with a Curves.easeInOutBack curve begin min-size', (WidgetTester tester) async {
const Key stackKey = ValueKey<String>('stack');
const Key containerKey = ValueKey<String>('container');
final DraggableScrollableController controller = DraggableScrollableController();
await tester.pumpWidget(boilerplateWidget(
null,
initialChildSize: 0.25,
controller: controller,
stackKey: stackKey,
containerKey: containerKey,
));
await tester.pumpAndSettle();
final double screenHeight = tester.getSize(find.byKey(stackKey)).height;
controller.animateTo(.6, curve: Curves.easeInOutBack, duration: const Duration(milliseconds: 500));
await tester.pumpAndSettle();
expect(
tester.getSize(find.byKey(containerKey)).height / screenHeight,
closeTo(.6, precisionErrorTolerance),
);
});
testWidgets('Can reuse a controller after the old controller is disposed', (WidgetTester tester) async {
const Key stackKey = ValueKey<String>('stack');
const Key containerKey = ValueKey<String>('container');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment