E/flutter ( 9348): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 'DateTime' is not a subtype of type 'Timestamp' in type cast
Here's the code:
//.......................................................
Widget inputDueDate() {
return Padding(padding: new EdgeInsets.only(left: 10.0, right: 10.0),
child: TextField(
onTap: ()=> ShowDateCalenddar(context, ).then((onValue){
Timestamp _dueDate = onValue as Timestamp; // Convert DateTime into timestamp so it can be stored into firebase document
}),
style: Theme.of(context).textTheme.body2,
controller: _dueDateController,
decoration: InputDecoration(labelText: homeworkConfig.dueDateLabel,
enabled: (widget.CRUDFlag == 'READ' ? false: true),
),
maxLines: 1,
),
);
}
Future<DateTime> ShowDateCalenddar(BuildContext context, ) async {
final DateTime picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2019, 1),
lastDate: DateTime(2101));
if (picked != null) {
setState(() {
_dueDateController = TextEditingController(text: picked.toString());
});
}
return picked;
}
onTap: () => ShowDateCalenddar(
context,
).then((onValue) {
printText('1. onValue', onValue.toString());
var _dueDate = onValue.millisecondsSinceEpoch; // Convert DateTime into timestamp so it can be stored into firebase document
printText('2. onValue.millisecondsSinceEpoch', _dueDate.toString());
DateTime _dueDate2 = DateTime.fromMicrosecondsSinceEpoch(_dueDate);
printText('3. DateTime.fromMicrosecondsSinceEpoch(_dueDate)', '$_dueDate2');
}),
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/8d2de50b-d6f4-43da-9106-81f9ad21b79d%40googlegroups.com.