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

Add generics support to methods #467

Open
codakkk opened this issue Sep 30, 2024 · 0 comments
Open

Add generics support to methods #467

codakkk opened this issue Sep 30, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@codakkk
Copy link

codakkk commented Sep 30, 2024

Environment

Package version: ^17.0.1

Description

Actually some if not allreactive_forms methods don't support generics meaning we have to manually cast to the right type each time. A normal way to avoid lots of as casts is using generics.

What you'd like to happen:

final form = ReactiveForm.of<FormGroup>(context); // returns a FormGroup
final c = form.control<String>('control-name'); // returns a FormControl<String>
final formArray = form.control<FormArray>('array-name'); // returns a FormArray
// and so on

Alternatives you've considered:
There's actually no alternative to "manual" casting.

final form = ReactiveForm.of(context) as FormGroup;
final c = form.control('control-name') as FormControl<String>
final formArray = form.control('array-name') as FormArray<dynamic>; // returns a FormArray

I can start working on this if makes sense to you.

@codakkk codakkk added the enhancement New feature or request label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant