Skip to content

Commit 4111f39

Browse files
[cupertino_ui] Forward showDragHandle from showCupertinoSheet to CupertinoSheetRoute (flutter#13011)
Port of flutter/flutter#187803 to `cupertino_ui`, following the process in flutter/flutter#188444. The original PR was approved by dkwingsmt and navaronbracke but couldn't land because of the Material/Cupertino code freeze. `showCupertinoSheet` accepts a `showDragHandle` parameter and documents what it does, but never passes it to the `CupertinoSheetRoute` it builds — so setting it to `true` has no effect. This forwards it on both paths (the plain route and the nested-navigation route). The regression test calls `showCupertinoSheet(showDragHandle: true)` and checks the drag handle is actually rendered. I checked that it fails with the forwarding removed and passes with it, in its new location under `packages/cupertino_ui/test/`. The original commit was cherry-picked as the porting guide describes. It hit one conflict: since the copy, `main` added `hasPlatformViews: hasPlatformViews` to the same two `CupertinoSheetRoute` constructor calls. I resolved it by keeping both arguments; the bug itself is still present on `main` (`showDragHandle` is declared but never forwarded). The only new commit adds the pending changelog entry (`version: patch`). Fixes flutter/flutter#187693 ## Pre-Review Checklist I used AI tooling while working on this, and reviewed and tested all of it myself. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 8dcefb4 commit 4111f39

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

‎packages/cupertino_ui/lib/src/sheet.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ Future<T?> showCupertinoSheet<T>({
218218
enableDrag: enableDrag,
219219
topGap: topGap,
220220
hasPlatformViews: hasPlatformViews,
221+
showDragHandle: showDragHandle,
221222
);
222223

223224
return Navigator.of(context, rootNavigator: true).push<T>(route);
@@ -263,6 +264,7 @@ Future<T?> showCupertinoSheet<T>({
263264
enableDrag: enableDrag,
264265
topGap: topGap,
265266
hasPlatformViews: hasPlatformViews,
267+
showDragHandle: showDragHandle,
266268
);
267269
return Navigator.of(context, rootNavigator: true).push<T>(route);
268270
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
changelog: |
2+
- Fixes `showCupertinoSheet` ignoring `showDragHandle` by forwarding it to `CupertinoSheetRoute`.
3+
version: patch

‎packages/cupertino_ui/test/sheet_test.dart‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,56 @@ void main() {
167167
expect(sheetContentOffset.dy, greaterThan(dragHandleOffset.dy));
168168
});
169169

170+
for (final useNestedNavigation in <bool>[false, true]) {
171+
testWidgets(
172+
'showCupertinoSheet forwards showDragHandle to the sheet route - use nested navigation $useNestedNavigation',
173+
(WidgetTester tester) async {
174+
// Regression test for https://github.com/flutter/flutter/issues/187693.
175+
final Finder dragHandleFinder = find.byWidgetPredicate((Widget widget) {
176+
return widget is DecoratedBox &&
177+
widget.decoration is ShapeDecoration &&
178+
(widget.decoration as ShapeDecoration).color == CupertinoColors.tertiaryLabel;
179+
});
180+
final GlobalKey scaffoldKey = GlobalKey();
181+
182+
await tester.pumpWidget(
183+
CupertinoApp(
184+
home: CupertinoPageScaffold(
185+
key: scaffoldKey,
186+
child: Center(
187+
child: Column(
188+
children: <Widget>[
189+
const Text('Page 1'),
190+
CupertinoButton(
191+
onPressed: () {
192+
showCupertinoSheet<void>(
193+
context: scaffoldKey.currentContext!,
194+
useNestedNavigation: useNestedNavigation,
195+
showDragHandle: true,
196+
scrollableBuilder:
197+
(BuildContext context, ScrollController scrollController) {
198+
return const CupertinoPageScaffold(child: Text('Page 2'));
199+
},
200+
);
201+
},
202+
child: const Text('Push Page 2'),
203+
),
204+
],
205+
),
206+
),
207+
),
208+
),
209+
);
210+
211+
await tester.tap(find.text('Push Page 2'));
212+
await tester.pumpAndSettle();
213+
214+
expect(find.text('Page 2'), findsOneWidget);
215+
expect(dragHandleFinder, findsOneWidget);
216+
},
217+
);
218+
}
219+
170220
testWidgets('Previous route moves slight downward when sheet route is pushed', (
171221
WidgetTester tester,
172222
) async {

0 commit comments

Comments
 (0)