Skip to content

Commit 8469896

Browse files
authored
Fix DDS do not support Curves.easeInOutBack curve (#114222)
1 parent cdbb1e6 commit 8469896

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart

+10-7
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,12 @@ class DraggableScrollableController extends ChangeNotifier {
136136
animationController.value,
137137
_attachedController!.position.context.notificationContext!,
138138
);
139-
if (animationController.value > _attachedController!.extent.maxSize ||
140-
animationController.value < _attachedController!.extent.minSize) {
141-
// Animation hit the max or min size, stop animating.
142-
animationController.stop(canceled: false);
143-
}
144139
});
145-
await animationController.animateTo(size, duration: duration, curve: curve);
140+
await animationController.animateTo(
141+
clampDouble(size, _attachedController!.extent.minSize, _attachedController!.extent.maxSize),
142+
duration: duration,
143+
curve: curve,
144+
);
146145
}
147146

148147
/// Jumps the attached sheet from its current size to the given [size], a
@@ -579,7 +578,11 @@ class _DraggableSheetExtent {
579578
/// or a user drag.
580579
void updateSize(double newSize, BuildContext context) {
581580
assert(newSize != null);
582-
_currentSize.value = clampDouble(newSize, minSize, maxSize);
581+
final double clampedSize = clampDouble(newSize, minSize, maxSize);
582+
if (_currentSize.value == clampedSize) {
583+
return;
584+
}
585+
_currentSize.value = clampedSize;
583586
DraggableScrollableNotification(
584587
minExtent: minSize,
585588
maxExtent: maxSize,

packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart

+24-3
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,7 @@ void main() {
950950
goTo(.5);
951951
await tester.pumpAndSettle();
952952
goTo(0);
953-
// The animation was cut short by half, there should have been on less pumps
954-
final int truncatedPumpCount = shouldAnimate ? expectedPumpCount - 1 : expectedPumpCount;
955-
expect(await tester.pumpAndSettle(), truncatedPumpCount);
953+
expect(await tester.pumpAndSettle(), expectedPumpCount);
956954
expect(
957955
tester.getSize(find.byKey(containerKey)).height / screenHeight,
958956
closeTo(.25, precisionErrorTolerance),
@@ -1007,6 +1005,29 @@ void main() {
10071005
);
10081006
});
10091007

1008+
testWidgets('Can animateTo with a Curves.easeInOutBack curve begin min-size', (WidgetTester tester) async {
1009+
const Key stackKey = ValueKey<String>('stack');
1010+
const Key containerKey = ValueKey<String>('container');
1011+
final DraggableScrollableController controller = DraggableScrollableController();
1012+
await tester.pumpWidget(boilerplateWidget(
1013+
null,
1014+
initialChildSize: 0.25,
1015+
controller: controller,
1016+
stackKey: stackKey,
1017+
containerKey: containerKey,
1018+
));
1019+
await tester.pumpAndSettle();
1020+
final double screenHeight = tester.getSize(find.byKey(stackKey)).height;
1021+
1022+
controller.animateTo(.6, curve: Curves.easeInOutBack, duration: const Duration(milliseconds: 500));
1023+
1024+
await tester.pumpAndSettle();
1025+
expect(
1026+
tester.getSize(find.byKey(containerKey)).height / screenHeight,
1027+
closeTo(.6, precisionErrorTolerance),
1028+
);
1029+
});
1030+
10101031
testWidgets('Can reuse a controller after the old controller is disposed', (WidgetTester tester) async {
10111032
const Key stackKey = ValueKey<String>('stack');
10121033
const Key containerKey = ValueKey<String>('container');

0 commit comments

Comments
 (0)