我试图在波斯日期中使用flutter datepicker,但是当我在日期选择器上单击时,出现此错误:
方法格式的完整日期被调用为空
我很陌生,我不确定是否使用了正确的语言环境和日期时间。 这是我的代码:
class ProfileSettingPage extends StatefulWidget {
@override
_ProfileSettingPageState createState() => _ProfileSettingPageState();
}
class _ProfileSettingPageState extends State<ProfileSettingPage> {
final TextEditingController _birthDayController = new TextEditingController();
DateTime selectedDate = DateTime.now();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: _buildProfileSetting(context),
),
);
}
_buildProfileSetting(BuildContext context) {
return Form(
child: ListView(
children: <Widget>[
Directionality(
textDirection: TextDirection.rtl,
child: TextField(
textInputAction: TextInputAction.go,
onChanged: (value) {},
onTap: () => _selectDate(context),
controller: _birthDayController,
decoration: InputDecoration(
enabled: true,
labelText: "birth day",
),
),
],
));
}
Future<Null> _selectDate(BuildContext context) async {
final DateTime picked = await showDatePicker(
context: context,
locale: Locale("fa"),
initialDate: selectedDate,
firstDate: DateTime(2015, 8),
lastDate: DateTime(2101));
if (picked != null && picked != selectedDate)
_birthDayController.text = picked.toIso8601String();
print(picked);
}
}
有什么想法吗?