Repository navigation
Make sure that a TextField doesn't crash in 0x0 environment - #178232
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a regression test to ensure that a TextField does not crash when it has a zero-size area. The test case correctly simulates the scenario by setting the view's physical size to zero and then triggering a selection change. My feedback includes a minor suggestion to improve test hygiene by reordering the addTearDown calls to follow the recommended resource cleanup order.
| addTearDown(controller.dispose); | ||
| addTearDown(tester.view.reset); |
There was a problem hiding this comment.
For better test hygiene, it's generally safer to dispose of resources in the reverse order of their allocation. In this test, the TextEditingController is created after the tester.view is modified. Therefore, the controller should be disposed of before resetting the view.
The addTearDown function executes callbacks in the reverse order of their registration. To ensure controller.dispose() is called before tester.view.reset(), you should register tester.view.reset first.1
addTearDown(tester.view.reset);
addTearDown(controller.dispose);Style Guide References
Footnotes
43b70df to
8cada9f
Compare
…178232) This is my attempt to handle flutter#6537 for the TextField widget.
…178232) This is my attempt to handle flutter#6537 for the TextField widget.
…178232) This is my attempt to handle flutter#6537 for the TextField widget.
This is my attempt to handle #6537 for the TextField widget.