-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make sure that a TextField doesn't crash in 0x0 environment #178232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure that a TextField doesn't crash in 0x0 environment #178232
Conversation
There was a problem hiding this comment.
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.