Make sure that a Form doesn't crash in 0x0 environment#180792
Conversation
There was a problem hiding this comment.
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'))), |
There was a problem hiding this comment.
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.
| child: SizedBox.shrink(child: Form(child: Text('X'))), | |
| child: SizedBox.shrink(child: Form(autovalidateMode: AutovalidateMode.always, child: Text('X'))), |
|
@ahmedsameha1 FYI there is a merge conflict, could you fix it before we merge this? |
This is my attempt to handle flutter#6537 for the Form widget. Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This is my attempt to handle #6537 for the Form widget.