Val
Val

Reputation: 101

CupertinoDatePicker using internationalization

I am fairly new to Fllutter. I am using Localization to define the app language in multiple countries. The App works in English without issues. If We change language Texts are correctly translated. But if we change the device language. My CupertinoDatePicker dates fails. Here is an example using Spanish as language. The error message reads "The method datePickerDayOfMonth was called on null". Here is a code sample:

                    Container(
                        margin: new EdgeInsets.fromLTRB(5.0, 1.0, 3.0, 3.0),
                        width: MediaQuery.of(context).size.width *.65,
                      child:
                        CupertinoTheme(
                          data: CupertinoThemeData(
                            textTheme: CupertinoTextThemeData(
                              dateTimePickerTextStyle: TextStyle(
                                fontSize: 12,
                              ),
                            ),
                          ),
                          child:
                          CupertinoDatePicker(
                            minimumDate: DateTime.now(),
                            mode: CupertinoDatePickerMode.date,
                            initialDateTime: DateTime.now(),
                            onDateTimeChanged: (dateTime) {
                              setState(() {
                                _followUpDate = dateTime;
                              });
                            },
                          )
                      )
                    )
                  ]
              )
            )
          )

Here is the device screen results:

Cupertino Date Pickers

Hope you may be able to help me. Look forward to hearing for solutions.

Upvotes: 1

Views: 2013

Answers (1)

Mo'men L-Ashmawy
Mo'men L-Ashmawy

Reputation: 118

try to add this in your main

localizationsDelegates: [
            GlobalCupertinoLocalizations.delegate,

          ],

Upvotes: 7

Related Questions