-
Notifications
You must be signed in to change notification settings - Fork 28.6k
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
Add isDismissible configuration for showModalBottomSheet #42404
Conversation
…sible by tapping on the scrim
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 What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
caae18f
to
96c55ba
Compare
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. |
|
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
/// The `isDismissible` parameter specifies whether the bottom sheet will be | |
/// The [isDismissible] parameter specifies whether the bottom sheet will be |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@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
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. |
@genert I do agree that the parameter name |
96c55ba
to
236652e
Compare
* Allow showModalBottomSheet to present bottom sheet that is not dismissible by tapping on the scrim * Add guards, improve styling and tests for BottomSheet
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.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?