-
Notifications
You must be signed in to change notification settings - Fork 29.7k
fix11068 InputDecoration 'errorText' custom builder #104165
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
fix11068 InputDecoration 'errorText' custom builder #104165
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). For more information, open the CLA check for this pull request. |
justinmc
left a comment
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.
Thanks for the PR (+@dancamdev and @ctechdev)! I agree that people probably do want to be able to specify a widget for the error and not just text. Some points that I'm noticing:
- Did you run an autoformatter on the code? It looks like there are lots of unrelated changes. We don't use dart format on the Flutter framework code.
- We'll need at least one test for this.
- I wonder if a parameter of type
Widgetwould be better than a builder function? Similar to label and labelText. Would that still work for you? - Should
helperTextalso have this kind of parameter?
|
Hi @justinmc, thanks for reviewing the code.
|
|
@justinmc upon further analysis on the current error implementation on both We're working on adding tests and |
|
Specifying an errorWidget instead of errorText seems sufficient, since the developer needs to specify one or the other for This PR reformats InputDecorator.dart; it should not. Please only change as much of the existing code as is necessary to make your change. Note also: tests for this new feature will be needed. |
|
+1 to the above. I'm not sure if there's an easy way to rollback the formatter changes or not. For tests, take a look at input_decorator_test.dart or maybe text_field_test.dart. |
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@dancamdev @Michele-x98 Are you guys still available to finish this PR? Let me know if there's anything blocking you. It looks like there is a merge conflict, but it's probably just due to the formatting changes in input_decorator.dart. |
|
@justinmc I removed the change due to autoformatting and added the errorWidget property as proposed, so it is not possible to define both errorText and errorWidget. The tests are missing for the moment, I have defined them but without implementing them at all. |
|
I like the idea to customise the style of an error messages in TextFields. But with a simple Shouldn't the API be like: |
|
@xvrh That's the point, you can't. Now with the simple errorWidget you can just add something under the field and it is permanently showed, without the builder you don't have access to the error message string if that is not null. In the previous version that i proposed, the builder method allow to take the message error in input and handle it as you want, but as @justinmc and @HansMuller said, that logic works only if the widget is "linked" to the errorText, and if the errorText is Null, the widget is never displayed. |
Unless I'm missing something, this is the behaviour we want. And if not, then we can also update the builder to be |
|
@xvrh I follow this logic above:
But i think that it also works as you propose as well, maybe the function could be Nullable and the return type Widget not?
This make more sense to me. |
|
any update on this? |
|
I'm closing this due to lack of activity. If you decide to resume working on it, please reopen the PR. |
Me, Daniele Cambi and Cosimo Tassone made this PR that allows to customize the errorText of an InputDecoration with an errorWidgetBuilder function that takes in input the errorText String that cames from InputDecoration, when it is not null, and allows to build a custom Widget for the error.
The default behavior doesn't change if the errorWidgetBuilder is not provided.
Without error widget builder:
With custom errorWidgetBuilder:
List which issues are fixed by this PR. You must list at least one issue.
Fixes #11068
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.