jRuMoL
jRuMoL

Reputation: 349

DateFormat class doesn't work for flutter_form_builder

I am using the flutter_form_builder package and for the FormBuilderDateTimePicker I am not able to introduce the "format" property. My code is:

FormBuilderDateTimePicker(
            name: 'fechaYhora',
            initialValue: DateTime.now(),
            initialDate: DateTime.now(),
            inputType: InputType.date,
            format: DateFormat('EEEE, dd MMMM, yyyy'),
            decoration: InputDecoration(
              icon: Icon(Icons.calendar_today_sharp),
              hintText: 'Elige una fecha y una hora',
            ),
          )

However, I get the following error message:

The method 'DateFormat' isn't defined for the type '_DarCitaState'. (Documentation)

And it is correctly imported.

Upvotes: 1

Views: 1537

Answers (1)

jRuMoL
jRuMoL

Reputation: 349

I was missing the following import file:

import 'package:intl/intl.dart';

Now it is fixed.

Upvotes: 4

Related Questions