Skip to content

Add FDialog.resizeToAvoidInsets to opt out of view inset padding#1005

Merged
Pante merged 2 commits intomainfrom
feature/dialog-insets
May 4, 2026
Merged

Add FDialog.resizeToAvoidInsets to opt out of view inset padding#1005
Pante merged 2 commits intomainfrom
feature/dialog-insets

Conversation

@Pante
Copy link
Copy Markdown
Member

@Pante Pante commented May 4, 2026

Describe the changes

Adds FDialog.resizeToAvoidInsets (default true) that lets callers opt out of MediaQuery.viewInsets being added to the dialog's outer padding.

  • Closes FDialog can be compressed to unusable height when bottom viewInsets are present #1004.
  • On Flutter Web/embedded environments, the host can report a large bottom view inset (e.g., a docked chat panel) that compresses FDialog into an unusable strip. Setting resizeToAvoidInsets: false keeps the dialog at its natural size.
  • Available on FDialog, FDialog.adaptive, and FDialog.raw. Not added to showFDialog/FDialogRoute since the viewInsets handling lives entirely inside _FDialogState.build; callers pass it through their builder.
  • Default true preserves existing behavior — purely additive, no fix_data migration needed.

Checklist

  • I have read the CONTRIBUTING.md.
  • I have included the relevant unit/golden tests.
  • I have included the relevant samples.
  • I have updated the documentation accordingly.
  • I have added the required flutters_hook for widget controllers.
  • I have updated the CHANGELOG.md if necessary.

🤖 Generated with Claude Code

Closes #1004.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 4, 2026 02:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 (default true) to FDialog, FDialog.adaptive, and FDialog.raw.
  • Update dialog layout to conditionally include MediaQuery.viewInsetsOf(context) in AnimatedPadding.
  • 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 resizeToAvoidInsets is set to false, the dialog stops adding MediaQuery.viewInsets to the outer AnimatedPadding, but it still wraps the content in MediaQuery.removeViewInsets(...). That means descendants can no longer read the real viewInsets (e.g., a custom FDialog.raw builder that wants to react to the keyboard), which is surprising given the name/description (“should avoid view insets”). Consider only removing viewInsets when resizeToAvoidInsets is true, or otherwise preserving the original MediaQuery for 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.
@Pante Pante merged commit c98ea59 into main May 4, 2026
18 checks passed
@Pante Pante deleted the feature/dialog-insets branch May 4, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FDialog can be compressed to unusable height when bottom viewInsets are present

2 participants