lundi 23 août 2021

When I use the TAB key to jump between FormField an error is thrown using Flutter WEB

I want to be able to use the TAB key to navigate between TextFormField using Flutter WEB. It works well on most of my Form but on one, it doesn't work.

Here the code that causes the problem :

    class __CreationFormState extends State<__CreationForm> {
  final _formKey = GlobalKey<FormState>();
  Project project;

  __CreationFormState({required this.project});

  @override
  Widget build(BuildContext context) {
    return Form(
      key: _formKey,
      child: Column(
        children: [
          NumberFormQuestion(
            initialValue: project.heisStudentsPcNb,
            onSaved: (heisStudentsPcNb) => setState(
                () => project.heisStudentsPcNb = int.parse(heisStudentsPcNb!)),
            question:
                'Expected implementation of Partner country "HEIs\' students" to be trained',
          ),
          NumberFormQuestion(
            initialValue: project.heisAcademicPcNb,
            onSaved: (heisAcademicPcNb) => setState(
                () => project.heisAcademicPcNb = int.parse(heisAcademicPcNb!)),
            question:
                'Expected implementation of Partner country "HEIs\' academy staff" to be trained',
          ),
          NumberFormQuestion(
            initialValue: project.heisAdminPcNumber,
            onSaved: (heisAdminPcNumber) => setState(() =>
                project.heisAdminPcNumber = int.parse(heisAdminPcNumber!)),
            question:
                'Expected implementation of Partner country "HEIs\' administrative staff" to be trained',
          ),
          NumberFormQuestion(
            initialValue: project.nonHeisNb,
            onSaved: (nonHeisNb) =>
                setState(() => project.nonHeisNb = int.parse(nonHeisNb!)),
            question:
                'Expected implementation of Partner country "non-HEIs\' individuals" to be trained',
          ),
          TextFormQuestion(
            initialValue: project.vulnerableGroupExtent,
            onSaved: (vulnerableGroupExtent) => setState(
                () => project.vulnerableGroupExtent = vulnerableGroupExtent),
            question:
                'To what extent will attention be given to vulnerable groups',
          ),
          NumberFormQuestion(
            initialValue: project.benefHeisAcademicNb,
            onSaved: (benefHeisAcademicNb) => setState(() =>
                project.benefHeisAcademicNb = int.parse(benefHeisAcademicNb!)),
            question:
                'Number of direct beneficiaries in the Partner country(ies) per year academic staff from HEIs',
          ),
          NumberFormQuestion(
            initialValue: project.benefHeisAdminNb,
            onSaved: (benefHeisAdminNb) => setState(
                () => project.benefHeisAdminNb = int.parse(benefHeisAdminNb!)),
            question:
                'Number of direct beneficiaries in the Partner country(ies) per year administrative staff from HEIs',
          ),
          NumberFormQuestion(
            initialValue: project.benefHeisStudentNb,
            onSaved: (benefHeisStudentNb) => setState(() =>
                project.benefHeisStudentNb = int.parse(benefHeisStudentNb!)),
            question:
                'Number of direct beneficiaries in the Partner country(ies) per year: HE students',
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              PrecedentButton(
                scrollToTop: widget.scrollToTop,
                bloc: BlocProvider.of<ProjectGeneralBloc>(context),
                event: GetThirdPage(project: project),
              ),
              NextButton(
                  scrollToTop: widget.scrollToTop,
                  formKey: _formKey,
                  text: "Submit",
                  bloc: BlocProvider.of<ProjectGeneralBloc>(context),
                  event: SubmitProject(project: project)),
            ],
          ),
        ],
      ),
    );
  }
}

and here is the error that is thrown :

context != null "Tried to get the bounds of a focus node that didn't have its context set yet.\nThe context needs to be set before trying to evaluate traversal policies. Setting the context is typically done with the attach method."

Thanks for your help.




Aucun commentaire:

Enregistrer un commentaire