Skip to content

Make sure that a Form doesn't crash in 0x0 environment#180792

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
ahmedsameha1:handle#6537-Form
Jan 21, 2026
Merged

Make sure that a Form doesn't crash in 0x0 environment#180792
auto-submit[bot] merged 3 commits into
flutter:masterfrom
ahmedsameha1:handle#6537-Form

Conversation

@ahmedsameha1

Copy link
Copy Markdown
Contributor

This is my attempt to handle #6537 for the Form widget.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Jan 10, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a test case to address an issue where a Form widget with zero area could crash. The new test verifies that a Form can be rendered with zero size. My feedback focuses on making the test more robust by ensuring it triggers the validation logic that was causing the crash, thereby fully covering the reported issue.

const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox.shrink(child: Form(child: Text('X'))),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To properly test the scenario described in issue #6537, autovalidateMode should be set to AutovalidateMode.always. This will trigger the validation logic within the FormState.build method, which is where the crash occurs when the Form has zero area and no View ancestor is found.

Suggested change
child: SizedBox.shrink(child: Form(child: Text('X'))),
child: SizedBox.shrink(child: Form(autovalidateMode: AutovalidateMode.always, child: Text('X'))),

@victorsanni victorsanni requested a review from dkwingsmt January 12, 2026 21:57
@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 13, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Jan 13, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jan 13, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 13, 2026
@justinmc

Copy link
Copy Markdown
Contributor

@ahmedsameha1 FYI there is a merge conflict, could you fix it before we merge this?

@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 14, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Jan 14, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 14, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 14, 2026
@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 20, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Jan 20, 2026
Merged via the queue into flutter:master with commit 7401f6a Jan 21, 2026
73 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 23, 2026
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Feb 10, 2026
This is my attempt to handle
flutter#6537 for the Form widget.

Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants