Reputation: 101
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:
Hope you may be able to help me. Look forward to hearing for solutions.
Upvotes: 1
Views: 2013
Reputation: 118
try to add this in your main
localizationsDelegates: [
GlobalCupertinoLocalizations.delegate,
],
Upvotes: 7