My custom class file is not parsing at all and it's causing build issues on my project
Custom Class not working well
Custom Code
import '../backend/backend.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class DaySessionsByClass {
ClassesRecord? classRecord;
List<SessionsRecord> sessions;
List<BookingsRecord> bookings;
DaySessionsByClass({
this.classRecord,
this.sessions = const [],
this.bookings = const [],
});
Future<List<DaySessionsByClass>> getRescheduledBookingsForToday(
String providerId) async {
final now = DateTime.now();
final todayStart = DateTime(now.year, now.month, now.day);
final tomorrowStart = todayStart.add(const Duration(days: 1));
// Query all bookings for this provider, rescheduled, with reschedule_time today
final bookingsQuery = await FirebaseFirestore.instance
.collection('bookings')
.where('provider',
isEqualTo: FirebaseFirestore.instance.doc(providerId))
.where('rescheduled', isEqualTo: true)
.where('reschedule_time',
isGreaterThanOrEqualTo: Timestamp.fromDate(todayStart))
.where('reschedule_time', isLessThan: Timestamp.fromDate(tomorrowStart))
.get();
// Group bookings by class_reference
final Map<String, List<BookingsRecord>> bookingsByClass = {};
for (var doc in bookingsQuery.docs) {
final booking = BookingsRecord.fromSnapshot(doc);
final classRef = booking.classReference?.id; // Use .id to get the classId
if (classRef != null) {
bookingsByClass.putIfAbsent(classRef, () => []).add(booking);
}
}
// Fetch ClassesRecord for each classId
List<DaySessionsByClass> results = [];
for (var entry in bookingsByClass.entries) {
final classId = entry.key;
final classDoc = await FirebaseFirestore.instance
.collection('classes')
.doc(classId)
.get();
final classRecord = ClassesRecord.fromSnapshot(classDoc);
results.add(DaySessionsByClass(
classRecord: classRecord,
bookings: entry.value,
));
}
return results;
}
}
This is my code and it was working fine but suddenly it can't be parsed anymore
No
1 reply