diff --git a/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart index 38e1bcc424..b8e4e16d8a 100644 --- a/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart +++ b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart @@ -623,8 +623,8 @@ class _DraggableSheetExtent { required bool snap, required List snapSizes, required double initialSize, - Duration? snapAnimationDuration, - bool shouldCloseOnMinExtent = true, + required Duration? snapAnimationDuration, + required bool shouldCloseOnMinExtent, }) { return _DraggableSheetExtent( minSize: minSize, @@ -744,6 +744,7 @@ class _DraggableScrollableSheetState extends State { snapSizes: _impliedSnapSizes(), snapAnimationDuration: widget.snapAnimationDuration, initialSize: widget.initialChildSize, + shouldCloseOnMinExtent: widget.shouldCloseOnMinExtent, ); // Modify the existing scroll controller instead of replacing it so that // developers listening to the controller do not have to rebuild their listeners. diff --git a/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart b/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart index 1b5fc12749..9bf10a0de9 100644 --- a/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart +++ b/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart @@ -1746,4 +1746,35 @@ void main() { areCreateAndDispose, ); }); + + testWidgets('DraggableScrollableSheet respects shouldCloseOnMinExtent', (WidgetTester tester) async { + final DraggableScrollableController controller = DraggableScrollableController(); + DraggableScrollableNotification? receivedNotification; + + Future pumpWidgetAndFling() async { + await tester.pumpWidget(boilerplateWidget( + null, + controller: controller, + shouldCloseOnMinExtent: false, + onDraggableScrollableNotification: (DraggableScrollableNotification notification) { + receivedNotification = notification; + return false; + }, + )); + + await tester.flingFrom(const Offset(0, 325), const Offset(0, -325), 200); + await tester.pumpAndSettle(); + } + + await pumpWidgetAndFling(); + expect(receivedNotification!.shouldCloseOnMinExtent, isFalse); + + receivedNotification = null; + controller.jumpTo(0.5); + + // Construct the widget a second time, to ensure didUpdateWidget is called. + await pumpWidgetAndFling(); + expect(receivedNotification!.shouldCloseOnMinExtent, isFalse); + controller.dispose(); + }); }