Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add isDismissible configuration for showModalBottomSheet #42404

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

Conversation

tjonganthony
Copy link
Contributor

Description

Currently showBottomSheet does not allow BottomSheet that is non-dismissible.
This change will allow an extra configuration that allows user to create a non-dismissible BottomSheet while keeping the original behaviour as the default.

Related Issues

Fixes #42395

Tests

I added the following tests:

Updated the existing test by adding details about default behaviour.
Created test to make sure bottom sheet is not dismissed when isDismissible is set to false.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Oct 10, 2019
@googlebot
Copy link

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

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Contributor

@mehmetf mehmetf left a comment

Choose a reason for hiding this comment

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

These look good to me too but I would like to get Hans' approval.

@mehmetf mehmetf requested a review from HansMuller October 10, 2019 14:22
Copy link
Contributor

@johnsonmh johnsonmh left a comment

Choose a reason for hiding this comment

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

LGTM

@tjonganthony tjonganthony force-pushed the feature/create-non-dismissible-bottomsheet branch from caae18f to 96c55ba Compare October 11, 2019 03:53
@genert
Copy link

genert commented Oct 11, 2019

I do not think "isDismissible" is a good variable name.

I do not know whether Flutter project has any naming convention for boolean variables but "is" is a verb, and verbs are inappropriate to represent an object's state.

Therefore "isDismissible" should simply become "dismissible".

You should only use verbs for accessor (getter / setter) methods where it makes more sense when boolean variable is an adjective.

@johnsonmh
Copy link
Contributor

@genert

is_ is a common verb name for booleans in dart. Non-imperative verb phrases are preferred for boolean names.

https://dart.dev/guides/language/effective-dart/design#prefer-a-non-imperative-verb-phrase-for-a-boolean-property-or-variable

Copy link
Contributor

@shihaohong shihaohong left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -428,6 +431,9 @@ class _ModalBottomSheetRoute<T> extends PopupRoute<T> {
/// that a modal [BottomSheet] needs to be displayed above all other content
/// but the caller is inside another [Navigator].
///
/// The `isDismissible` parameter specifies whether the bottom sheet will be
Copy link
Contributor

@shihaohong shihaohong Oct 11, 2019

Choose a reason for hiding this comment

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

Using square brackets creates a hyperlink to the parameter in question in the API documentation.

Suggested change
/// The `isDismissible` parameter specifies whether the bottom sheet will be
/// The [isDismissible] parameter specifies whether the bottom sheet will be

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


await tester.pumpWidget(MaterialApp(
home: Builder(
builder: (BuildContext context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Still has 4 spaces instead of 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@genert
Copy link

genert commented Oct 12, 2019

@johnsonmh Interesting, thanks for the reference.

But if you look further, you find this - https://dart.dev/guides/language/effective-dart/design#consider-omitting-the-verb-for-a-named-boolean-parameter

For named parameters that are boolean, the name is often just as clear without the verb, and the code reads better at the call site.

Example:

Isolate.spawn(entryPoint, message, paused: false);
var copy = List.from(elements, growable: true);
var regExp = RegExp(pattern, caseSensitive: false);

Which is succinct as verb doesn't give any new information as stated in the documentation. Compare to:

Isolate.spawn(entryPoint, message, isPaused: false);
var copy = List.from(elements, isGrowable: true);
var regExp = RegExp(pattern, isCaseSensitive: false);

Since "isDismissable" is named parameter, then this rule should apply.

@tjonganthony
Copy link
Contributor Author

tjonganthony commented Oct 12, 2019

@genert I do agree that the parameter name dismissible is sufficient to explain the desired behavior change. However, considering the other existing parameters all have verb prepended in front of them, I'm leaning toward going for consistency since the added verb does no big harm.
Thanks for pointing out that reference though :)

@tjonganthony tjonganthony force-pushed the feature/create-non-dismissible-bottomsheet branch from 96c55ba to 236652e Compare October 12, 2019 16:27
@shihaohong shihaohong merged commit dd43da7 into flutter:master Oct 14, 2019
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Nov 26, 2019
* Allow showModalBottomSheet to present bottom sheet that is not dismissible by tapping on the scrim

* Add guards, improve styling and tests for BottomSheet
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alllow BottomSheet to be not dismissible by tapping on scrim
8 participants