Skip to content
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

Proposal to make the value of a FormControl non-null #345

Open
DevNico opened this issue Dec 9, 2022 · 6 comments
Open

Proposal to make the value of a FormControl non-null #345

DevNico opened this issue Dec 9, 2022 · 6 comments

Comments

@DevNico
Copy link

DevNico commented Dec 9, 2022

Currently when defining a FormControl we usually give it a Type. This type is then made nullable internally in the FormControl. The problem with this approach is that we might not want that behaviour.

A solution (breaking change) would be to require the value parameter in the FormControl constructor. This would still allow nullable values by defining a nullable type parameter and then passing null as the initial value therefore not taking any features away.

I've actually been faced with the same decision when migrating flutter_hooks to null-safety. The useState hook works in this fashion and I feel like FormControls should work the same way.

Please let me know your opinion on this matter!

@vasilich6107
Copy link
Contributor

Technically you might be correct but the amount of brake this feature could cause is gigantic.
You could take a look at https://pub.dev/packages/reactive_forms_generator which solves the form dynamicity issue in a bit different way

@DevNico
Copy link
Author

DevNico commented Dec 15, 2022

I'm not a fan of introducing another dependency let alone another code generator into our projects. I do think this would be a great improvement to the library and bring many benefits in the long run.

@vasilich6107
Copy link
Contributor

You can try to convince @joanpablo

@kuhnroyal
Copy link
Contributor

I also think this would be the best way forward. Improve the typing, I actually did that a while ago when fixing other typing issues but @joanpablo and I agreed that this was too much change at the time.

I now think this should be reevaluated for a new major version.

@DevNico
Copy link
Author

DevNico commented Dec 20, 2022

I'd be happy to start working on a PR if @joanpablo agrees that this is the way to go.

@vasilich6107
Copy link
Contributor

If this will help to get rid from nullable arrays in FormArray im 100% with you.
The stronger typing is - the better I feel)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants