ahmedoid / hijri_picker

Flutter Widget to Pick Hijri Calendar Dates
BSD 2-Clause "Simplified" License
25 stars 23 forks source link

Invalid argument: Instance of 'HijriCalendar' error #4

Closed Samar777 closed 3 years ago

Samar777 commented 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, }); }); } }

Samar777 commented 3 years ago

I solved it by converting selectedDate Object to string