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

Using canPop/onPopInvoked causes FormControlParentNotFoundException #162

Closed
TrplM opened this issue May 22, 2024 · 2 comments
Closed

Using canPop/onPopInvoked causes FormControlParentNotFoundException #162

TrplM opened this issue May 22, 2024 · 2 comments

Comments

@TrplM
Copy link

TrplM commented May 22, 2024

Using canPop or onPopInvoked throws FormControlParentNotFoundException: ReactiveFormField widget couldn't find a parent widget. An instance of ReactiveFormConsumer widget must be under a ReactiveForm or a ReactiveFormArray in the widgets tree.

Example

dependencies:
  reactive_forms: ^17.0.1
  reactive_forms_annotations: ^5.0.0

dev_dependencies:
  build_runner: ^2.4.9
  reactive_forms_generator: ^5.0.1
@Rf()
class Basic {
  final String email;

  Basic({
    @RfControl() this.email = '',
  });
}

class Repro extends StatelessWidget {
  const Repro({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: BasicFormBuilder(
        // setup form model with initial data
        model: Basic(),
        canPop: (formGroup) => true,
        onPopInvoked: (formGroup, didPop) => {},
        // form builder
        builder: (context, formModel, child) {
          return Column(
            children: [
              ReactiveTextField<String>(
                formControl: formModel.emailControl,
                decoration: const InputDecoration(labelText: 'Email'),
              ),
              const SizedBox(height: 8.0),
              ReactiveBasicFormConsumer(
                builder: (context, form, child) {
                  return ElevatedButton(
                    onPressed: form.form.valid
                        ? () {
                            print(form.model.email);
                          }
                        : null,
                    child: const Text('Submit'),
                  );
                },
              ),
            ],
          );
        },
      ),
    );
  }
}
@vasilich6107
Copy link
Contributor

Hey
Thanks for finding, check reactive_forms_generator 5.0.3
will add generated popscope class a little bit later

Copy link

Hi @TrplM!
Your issue has been closed. If we were helpful don't forget to star the repo.

Please check our reactive_forms_widget package

We would appreciate sponsorship subscription or one time donation
https://github.com/sponsors/artflutter

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

2 participants