-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Fix InputDecoration does not apply errorStyle to error #174787
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
Fix InputDecoration does not apply errorStyle to error #174787
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 correctly fixes an issue where InputDecoration.errorStyle
was not applied to the InputDecoration.error
widget. The implementation is sound and a regression test has been added to verify the fix. My feedback includes a suggestion to enhance the test coverage by adding a test case for custom errorStyle
to ensure all scenarios are covered.
2de498c
to
5281771
Compare
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.
LGTM
buildInputDecorator(decoration: const InputDecoration(error: Text(errorText))), | ||
); | ||
|
||
expect(findError(), findsOneWidget); |
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.
Reading the documentation of findsOneWidget
, it is written that
This is equivalent to the preferred [findsOne] method.
Should we be using findsOne
instead of findsOneWidget
?
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.
Should we be using findsOne instead of findsOneWidget?
Interesting question!
Searching through the codebase:
- findsOne: 8218
- findsOneWidget: 7610
In input_decorator_test.dart file, there are no occurences of findsOne
, only findsOneWidget
.
The reason is probably because findsOne
was introduced somewhat recently, see #127137.
I would say using findsOneWidget when we are looking for a Widget is ok, but maybe @justinmc has some thinking about this.
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.
I did some major archaeology here and my conclusion is that we should actually be using findsOne and not findsOneWidget! See these two comment threads:
- Adds SemanticsNode Finders for searching the semantics tree #127137 (comment)
- Adds SemanticsNode Finders for searching the semantics tree #127137 (comment)
It seems like there was a long-term plan to deprecate findsOneWidget, but the people involved are no longer working on Flutter.
So I guess strictly this PR should be changed to use findsOne. And I should stop using findsOneWidget like I have been for all my time on Flutter.
But in reality, both are equivalent and it doesn't really matter. I'll just keep this fact in my head in case anyone ever comes along with the motivation to clean up these duplicate methods and do the deprecation.
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.
I see, thank you for those insights @justinmc. Is there something blocking us from deprecated findsOneWidget
and other similar finders today?
If not, I could open PRs to deprecate them and migrate to findsOne
and similar finders
5281771
to
0dc7383
Compare
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.
LGTM 👍. Sorry for the delay on this! Treat my comment below as a total nit.
buildInputDecorator(decoration: const InputDecoration(error: Text(errorText))), | ||
); | ||
|
||
expect(findError(), findsOneWidget); |
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.
I did some major archaeology here and my conclusion is that we should actually be using findsOne and not findsOneWidget! See these two comment threads:
- Adds SemanticsNode Finders for searching the semantics tree #127137 (comment)
- Adds SemanticsNode Finders for searching the semantics tree #127137 (comment)
It seems like there was a long-term plan to deprecate findsOneWidget, but the people involved are no longer working on Flutter.
So I guess strictly this PR should be changed to use findsOne. And I should stop using findsOneWidget like I have been for all my time on Flutter.
But in reality, both are equivalent and it doesn't really matter. I'll just keep this fact in my head in case anyone ever comes along with the motivation to clean up these duplicate methods and do the deprecation.
Thanks for the review 🙏 |
Description
This PR fixes
InpuDecorator
not applyingInputDecoration.errorStyle
toInputDecoration.error
.Before
Text from
InputDecoration.error
is not styled correctly:After
Text from
InputDecoration.error
is styled correctly:Related Issue
Fixes InputDecorator does not apply errorStyle to error
Tests
Adds 1 test.