dart – method onSaved is never called with DateRangeField of package date_range_form_field in Flutter

I just took over a flutter project developed by another person, and I’m a beginner on this language.

While pulling his project, I had to modify 2 dependencies: intl:^0.16.2 to int: ^0.17.0, and also date_range_form_field:^0.0.5 to date_range_form_field:^1.0.2 to make the project run. I guess it’s because I wasn’t using the same version of the SDK as him.

However, by modifying these dependencies, one of the features was broken. Indeed, at the time of validating a form containing the DateRangeField element, seems incomplete and I can’t move on.

By debugging a little, I could realize that the onSaved method below did not seem to be called, because the debug message never appears in the logs.

class _DatesGarantieInput extends StatelessWidget {
  final format = DateFormat('dd/MM/yyyy');

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<CreationActifBloc, CreationActifState>(
      buildWhen: (previous, current) =>
          previous.datesGarantie != current.datesGarantie,
      builder: (context, state) {
        return DateRangeField(
          // context: context,
          dateFormat: format,
          margin: const EdgeInsets.all(0.0),
          key: const Key('creationActifForm_datesGarantieInput_dateRangeField'),
          onSaved: (datesGarantie) {
            print("here ???");
            return context
                .read<CreationActifBloc>()
                .add(CreationActifDatesGarantieChanged(datesGarantie));
          },
          helpText: 'Sélectionnez une période',
          cancelText: 'ANNULER',
          confirmText: 'OK',
          saveText: 'SAUVEGARDER',
          fieldStartLabelText: 'Date de début',
          fieldEndLabelText: 'Date de fin',
          decoration: InputDecoration(
            labelText: 'Dates de garantie',
            icon: const Icon(Icons.date_range),
            errorText: state.datesGarantie.invalid
                ? 'Dates de garantie invalides'
                : null,
          ),
        );
      },
    );
  }

Do you have any idea what is the problem here? Were there any major evolutions between the 2 versions of the date_range_form_field package?

Thanks a lot 🙂