Repository navigation
[material_ui] Migrate TextField, TextFormField, SelectableText, TextSelectionTheme, and SearchDelegate API doc snippets to {@example} (batch 17) - #13729
Conversation
…electionTheme, and SearchDelegate API doc snippets to {@example} (batch 17)
There was a problem hiding this comment.
Code Review
This pull request extracts inline code snippets from documentation comments into standalone example files and adds corresponding unit tests for several widgets, including SearchDelegate, SelectableText, TextField, TextFormField, and TextSelectionTheme. Feedback is provided on the TextField buildCounter snippet to handle the nullable maxLength parameter gracefully, preventing the string 'null' from being displayed when no maximum length is specified.
| return Text( | ||
| '$currentLength of $maxLength characters', | ||
| semanticsLabel: 'character count', | ||
| ); |
There was a problem hiding this comment.
The maxLength parameter is nullable (int?). If maxLength is null, string interpolation will display '0 of null characters', which is a poor user experience. It is better to handle the null case gracefully by only displaying the current length when maxLength is not provided.
| return Text( | |
| '$currentLength of $maxLength characters', | |
| semanticsLabel: 'character count', | |
| ); | |
| return Text( | |
| maxLength == null ? '$currentLength characters' : '$currentLength of $maxLength characters', | |
| semanticsLabel: 'character count', | |
| ); |
This PR addresses batch 17 of the migration detailed in flutter/flutter#188530 (comment).
Pre-Review Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2