使用国际化的 CupertinoDatePicker
CupertinoDatePicker using internationalization
我对 Fllutter 还很陌生。我正在使用本地化来定义多个国家/地区的应用程序语言。该应用程序以英语运行,没有任何问题。如果我们更改语言文本已正确翻译。但是如果我们改变设备语言。我的 CupertinoDatePicker 日期失败。这是使用西班牙语作为语言的示例。错误消息显示为 "The method datePickerDayOfMonth was called on null"。这是一个代码示例:
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;
});
},
)
)
)
]
)
)
)
这是设备屏幕结果:
希望你能帮到我。期待听到解决方案。
尝试将此添加到您的主
localizationsDelegates: [
GlobalCupertinoLocalizations.delegate,
],
我对 Fllutter 还很陌生。我正在使用本地化来定义多个国家/地区的应用程序语言。该应用程序以英语运行,没有任何问题。如果我们更改语言文本已正确翻译。但是如果我们改变设备语言。我的 CupertinoDatePicker 日期失败。这是使用西班牙语作为语言的示例。错误消息显示为 "The method datePickerDayOfMonth was called on null"。这是一个代码示例:
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;
});
},
)
)
)
]
)
)
)
这是设备屏幕结果:
希望你能帮到我。期待听到解决方案。
尝试将此添加到您的主
localizationsDelegates: [
GlobalCupertinoLocalizations.delegate,
],