Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add enableDrag property to CupertinoSheetRoute and showCupertinoSheet #163923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 25, 2025

Conversation

masal9pse
Copy link
Contributor

@masal9pse masal9pse commented Feb 22, 2025

Implemented. (#163852)

This PR adds the enableDrag option to showCupertinoSheet and CupertinoSheetRoute, allowing developers to control whether the sheet can be dismissed by dragging.

How to Verify

  • Set enableDrag: false in CupertinoSheetRoute or showCupertinoSheet.
CupertinoSheetRoute<void>(
      builder: (BuildContext context) => const _SheetScaffold(),
      enableDrag: false,
 ),

// or

showCupertinoSheet<void>(
      context: context,
      useNestedNavigation: true,
      pageBuilder: (BuildContext context) => const _SheetScaffold(),
      enableDrag: false,
 );
  • The following is a screenshot of examples/api/lib/cupertino/sheet/cupertino_sheet.0.dart after adding enableDrag: false.
2025-02-22.23.10.04.mov

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Copy link

google-cla bot commented Feb 22, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Feb 22, 2025
@masal9pse masal9pse changed the base branch from main to master February 22, 2025 11:01
@masal9pse masal9pse changed the title Add the enableDrag property to CupertinoSheetRoute to control whether… Add enableDrag property to CupertinoSheetRoute and showCupertinoSheet Feb 22, 2025
@masal9pse masal9pse marked this pull request as ready for review February 22, 2025 15:02
Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting this PR! Test looks great. Ideally I'd like to keep the buildPageTransitions method static. It might break some people to change it now, and it seems like we should be able to keep it static.

Besides that, I have some small comments on the documentation.

/// Returns a [CupertinoSheetTransition].
static Widget buildPageTransitions<T>(
Widget buildPageTransitions(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep this as static if we add an enableDrag argument, then pass it in inside of buildTransitions. Keeping it static is more likely to help with performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix this commit
9720184

@@ -581,8 +584,13 @@ mixin _CupertinoSheetRouteTransitionMixin<T> on PageRoute<T> {
);
}

/// Determines whether the content can be scrolled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: replace "scroll" with "drag". So "can be dragged to dismiss the sheet", "dragging is enabled". Scrolling refers to a slightly different interaction.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix this commit
0ebeb39

packages/flutter/lib/src/cupertino/sheet.dart Show resolved Hide resolved
@@ -1076,5 +1076,74 @@ void main() {
await gesture.up();
await tester.pumpAndSettle();
});

testWidgets('dragging does not move the sheet when enableDrag is false', (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍

@masal9pse
Copy link
Contributor Author

@MitchellGoodwin
Thank you for the review! I've addressed the feedback, so please take a look when you have a moment.

@KlausJokisuo
Copy link

I'm not sure how much additional work it would take to add support for Sheet Detents, which adds to the size support to the sheets (https://developer.apple.com/design/human-interface-guidelines/sheets), in this same PR.

@masal9pse 🙏

@masal9pse
Copy link
Contributor Author

masal9pse commented Mar 15, 2025

@KlausJokisuo
After lightly modifying the dragEnd method and then changing to Medium detent size, there are some things that need to be fixed, such as the back screen not being fully displayed, and I don't think this feature can be released with a simple fix.........

Therefore, I think PR should be separated.

@MitchellGoodwin
Copy link
Contributor

In general it's much better if work can be separated into different PRs. So even if it was simple to detents, it would be preferable if that was done in a separate PR. It makes things like documentation and diagnosing tree errors much cleaner.

Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the PR! Next this needs a second reviewer. I'll ask around.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MitchellGoodwin MitchellGoodwin force-pushed the add-enabledrag-cupertinosheet branch from d3031ef to 7a0035c Compare March 18, 2025 21:48
@MitchellGoodwin
Copy link
Contributor

Rebased it since Google testing failure was infra related.

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 19, 2025
Copy link
Contributor

auto-submit bot commented Mar 19, 2025

autosubmit label was removed for flutter/flutter/163923, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 19, 2025
@MitchellGoodwin MitchellGoodwin added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 25, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Mar 25, 2025
Merged via the queue into flutter:master with commit 71be3b1 Mar 25, 2025
76 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 25, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
zhangyuang pushed a commit to zhangyuang/flutter-fork that referenced this pull request Jun 9, 2025
…flutter#163923)

Implemented. (flutter#163852)

This PR adds the `enableDrag` option to showCupertinoSheet and
CupertinoSheetRoute, allowing developers to control whether the sheet
can be dismissed by dragging.

## How to Verify
- Set enableDrag: false in CupertinoSheetRoute or showCupertinoSheet.

```dart

CupertinoSheetRoute<void>(
      builder: (BuildContext context) => const _SheetScaffold(),
      enableDrag: false,
 ),

// or

showCupertinoSheet<void>(
      context: context,
      useNestedNavigation: true,
      pageBuilder: (BuildContext context) => const _SheetScaffold(),
      enableDrag: false,
 );

```

- The following is a screenshot of
`examples/api/lib/cupertino/sheet/cupertino_sheet.0.dart` after adding
`enableDrag: false`.



https://github.com/user-attachments/assets/315fb0e5-ceee-4150-be6e-dd919a7c2317

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.