Add FDialog.resizeToAvoidInsets to opt out of view inset padding#1005
Merged
Add FDialog.resizeToAvoidInsets to opt out of view inset padding#1005
Conversation
Closes #1004. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-out on FDialog so callers can prevent MediaQuery.viewInsets from being applied to the dialog’s outer padding (helpful on Web/embedded hosts that report large bottom insets), while keeping the default behavior unchanged.
Changes:
- Add
FDialog.resizeToAvoidInsets(defaulttrue) toFDialog,FDialog.adaptive, andFDialog.raw. - Update dialog layout to conditionally include
MediaQuery.viewInsetsOf(context)inAnimatedPadding. - Add widget tests covering the new flag’s padding behavior and constructor defaults; update changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| forui/lib/src/widgets/dialog/dialog.dart | Introduces resizeToAvoidInsets and applies it to the dialog’s outer padding computation. |
| forui/test/src/widgets/dialog/dialog_test.dart | Adds tests asserting bottom padding behavior with/without viewInsets and default constructor values. |
| forui/CHANGELOG.md | Documents the new FDialog.resizeToAvoidInsets API addition. |
Comments suppressed due to low confidence (1)
forui/lib/src/widgets/dialog/dialog.dart:513
- When
resizeToAvoidInsetsis set tofalse, the dialog stops addingMediaQuery.viewInsetsto the outerAnimatedPadding, but it still wraps the content inMediaQuery.removeViewInsets(...). That means descendants can no longer read the realviewInsets(e.g., a customFDialog.rawbuilder that wants to react to the keyboard), which is surprising given the name/description (“should avoid view insets”). Consider only removing viewInsets whenresizeToAvoidInsetsistrue, or otherwise preserving the originalMediaQueryfor the subtree when opting out.
return AnimatedPadding(
padding:
(widget.resizeToAvoidInsets ? MediaQuery.viewInsetsOf(context) : EdgeInsets.zero) +
style.insetPadding.resolve(direction),
duration: style.motion.insetDuration,
curve: style.motion.insetCurve,
child: MediaQuery.removeViewInsets(
removeLeft: true,
removeTop: true,
removeRight: true,
removeBottom: true,
context: context,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+281
to
+284
| /// Whether the dialog should avoid the system's view insets, typically the keyboard. Defaults to true. | ||
| /// | ||
| /// Set this to false to avoid the dialog from becoming overly compressed on web & embedded platforms where the view | ||
| /// insets comes from the surrounding host/browser environment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the changes
Adds
FDialog.resizeToAvoidInsets(defaulttrue) that lets callers opt out ofMediaQuery.viewInsetsbeing added to the dialog's outer padding.FDialoginto an unusable strip. SettingresizeToAvoidInsets: falsekeeps the dialog at its natural size.FDialog,FDialog.adaptive, andFDialog.raw. Not added toshowFDialog/FDialogRoutesince the viewInsets handling lives entirely inside_FDialogState.build; callers pass it through their builder.truepreserves existing behavior — purely additive, nofix_datamigration needed.Checklist
🤖 Generated with Claude Code