Make sure that a TextFormField doesn't crash in 0x0 environment#178233
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a regression test for an issue where TextFormField would crash in a 0x0 environment when its selection changes. The test correctly sets up the 0x0 environment and triggers a selection change. My feedback includes a suggestion to make the test more thorough by covering the specific scenario of changing to a non-collapsed selection, as mentioned in the original issue report, and to await the pump call for correctness and consistency.
| controller.selection = const TextSelection.collapsed(offset: 0); | ||
| tester.pump(); |
There was a problem hiding this comment.
The issue description mentions that the crash occurred when changing "from a collapsed selection to a non-collapsed selection". This test only covers changing to a collapsed selection. It would be more thorough to also test changing to a non-collapsed selection to fully cover the reported issue.1
Also, tester.pump() returns a Future and should be awaited for consistency with other tests in this file.
controller.selection = const TextSelection.collapsed(offset: 0);
await tester.pump();
// Check that changing to a non-collapsed selection also doesn't crash.
controller.selection = const TextSelection(baseOffset: 0, extentOffset: 1);
await tester.pump();Style Guide References
Footnotes
-
Tests should be effective and cover the reported issue thoroughly. The suggestion improves the test by adding coverage for the specific case mentioned in the issue description. ↩
…ter#178233) This is my attempt to handle flutter#6537 for the TextFormField widget.
…ter#178233) This is my attempt to handle flutter#6537 for the TextFormField widget.
…ter#178233) This is my attempt to handle flutter#6537 for the TextFormField widget.
This is my attempt to handle #6537 for the TextFormField widget.