Closed Samar777 closed 3 years ago
Hi,
when I try to pick a date then press ok this error appears:
ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: Invalid argument: Instance of 'HijriCalendar'
my code: Future _selectDate(BuildContext context) async { final HijriCalendar picked = await showHijriDatePicker( context: context, initialDate: selectedDate, lastDate: new HijriCalendar() ..hYear = 1445 ..hMonth = 9 ..hDay = 25, firstDate: new HijriCalendar() ..hYear = 1438 ..hMonth = 12 ..hDay = 25, initialDatePickerMode: DatePickerMode.day, ); if (picked != null) setState(() { selectedDate = picked; }); book();
}
book() { User user = FirebaseAuth.instance.currentUser; final uid = user.uid; if (selectedDate != null) { FirebaseFirestore.instance .collection('/profiles') .where('Uid', isEqualTo: uid) .get() .then((val) { FirebaseFirestore.instance.collection('/photography').add({ 'KitchenUid': uid, 'kitchenMobile': val.docs[0].data()['Mobile'], 'date': selectedDate, }); }); } }
I solved it by converting selectedDate Object to string
Hi,
when I try to pick a date then press ok this error appears:
ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: Invalid argument: Instance of 'HijriCalendar'
my code: Future _selectDate(BuildContext context) async {
final HijriCalendar picked = await showHijriDatePicker(
context: context,
initialDate: selectedDate,
lastDate: new HijriCalendar()
..hYear = 1445
..hMonth = 9
..hDay = 25,
firstDate: new HijriCalendar()
..hYear = 1438
..hMonth = 12
..hDay = 25,
initialDatePickerMode: DatePickerMode.day,
);
if (picked != null)
setState(() {
selectedDate = picked;
});
book();
}
book() { User user = FirebaseAuth.instance.currentUser; final uid = user.uid; if (selectedDate != null) { FirebaseFirestore.instance .collection('/profiles') .where('Uid', isEqualTo: uid) .get() .then((val) { FirebaseFirestore.instance.collection('/photography').add({ 'KitchenUid': uid, 'kitchenMobile': val.docs[0].data()['Mobile'], 'date': selectedDate, }); }); } }