Expose insetPadding and clipBehavior in Dialog and AlertDialog.#50775
Expose insetPadding and clipBehavior in Dialog and AlertDialog.#50775fluttergithubbot merged 4 commits intoflutter:masterfrom darrenaustin:dialog_padding
Conversation
| final Curve insetAnimationCurve; | ||
|
|
||
| /// {@template flutter.material.dialog.insetPadding} | ||
| /// The amount of padding added to the outside of the dialog. |
There was a problem hiding this comment.
I'm not sure what the right way to describe this is, but I'm assuming this means the padding between the edges of the screen and the dialog itself? I had to think about this for a while and confused between that meaning and the padding between the edges of the dialog and its contents.
Also, do we only see this when the dialog is expanded to be as large as it can be? If I recall correctly, the dialog will be smaller if there the dialog's contents are small enough
There was a problem hiding this comment.
Yup. I struggled with that too. I will try come up with a better description.
| }) : assert(clipBehavior != null) | ||
| , super(key: key); |
There was a problem hiding this comment.
I think this is typically formatted this way:
}) : assert(clipBehavior != null),
super(key: key);There was a problem hiding this comment.
I could have sworn I have seen it this way in other files, but looking at the style guidelines again, you are indeed correct. Thx. I will fix that shortly.
| }) : assert(contentPadding != null) | ||
| , assert(clipBehavior != null) | ||
| , super(key: key); |
There was a problem hiding this comment.
}) : assert(contentPadding != null),
assert(clipBehavior != null),
super(key: key);Co-Authored-By: Shi-Hao Hong <shihaohong@google.com>
| /// {@template flutter.material.dialog.insetPadding} | ||
| /// The amount of padding added to the outside of the dialog. | ||
| /// The amount of padding added to [MediaQueryData.viewInsets] on the outside | ||
| /// of the dialog. This defines the minimum space between the screen's edges |
There was a problem hiding this comment.
Nice, this last sentence makes it very clear!
| this.backgroundColor, | ||
| this.elevation, | ||
| this.semanticLabel, | ||
| this.insetPadding = const EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0), |
There was a problem hiding this comment.
Wondering if this const EdgeInsets should be factored into a constant since its used twice.
There was a problem hiding this comment.
Good catch. Just updated to include this.
|
@darrenaustin could you please clarify why Because if it was unintended (without any actual reason), I could create PR with such addition. I need to have the possibility to reduce the height of |
|
@ycherniavskyi This was just an oversight. A PR to add them to |
Description
Currently the
Dialogclass has a hard coded padding used for the outer part of the dialog. This makes it hard for large dialogs like the Date Picker to use more of the screen. In addition, there is no way to specify theclipBehaviorused by the Dialog's internalMaterialwidget. This means that there is no way to have the dialog's content clipped to the given shape, as it defaults toClip.none.This PR exposes new
insetPaddingandclipBehaviorparameters to the constructors for theDialogandAlertDialogclasses.Related Issues
Closes #50757
Tests
I added tests to the
dialog_test.dartthat tests both of these parameters.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
Did any tests fail when you ran them? Please read Handling breaking changes.