booking_calendar
booking_calendar copied to clipboard
Flutterflow project from Firebase example for download
The custom widget you guys have done is great, but unfortunately I'm not very good with flutter and had trouble connecting the widget with my firebase database and displaying its data + creating documents for new bookings.
I was wondering if you could share the flutterflow project from the firebase example so we can exactly replicate the widget and action you made in the firebase example.
It would be really helpful as I've been trying to put together the widget code for days and just haven't hit the nail.
Thanks in advance.
Im in the same place and trying to figure this out now. @FerTirado let me know if you get anywhere.
Personally would love to see another mock example connecting it to firebase.
Add:
// Get a reference to the Firestore database final firestore = FirebaseFirestore.instance;
Then update your getBookingStreamMock to: (my collection is called privateSessions so change that to your collection - you will need a start_time and end_time timestamp)
Stream<dynamic> getBookingStreamMock({DateTime? end, DateTime? start}) {
return firestore.collection("privateSessions").snapshots().map((snapshot) {
return snapshot.docs.map((doc) {
var data = doc.data();
return DateTimeRange(
start: data["start_time"].toDate(),
end: data["end_time"].toDate(),
);
}).toList();
});
}
The getBookingStream will query a list of booked appointments.
My class Call looks like this - bookingPage gives me the ability to apply an action in Flutterflow whenever someone clicks on book -
class Cal extends StatefulWidget {
const Cal({
Key? key,
this.width,
this.height,
required this.bookingPage,
}) : super(key: key);
final double? width;
final double? height;
final Future<dynamic> Function() bookingPage;
@override
State<Cal> createState() => _CalState();
}
The last thing I've done so far is update the local state with the time selected so I can use that in my FlutterFlow action output. Here's the code I used to do that. My flutterflow local state is called privateDate
Future<dynamic> uploadBookingMock({BookingService? newBooking}) async {
await Future.delayed(const Duration(seconds: 1));
FFAppState().update(() {
FFAppState().privateDate = newBooking!.bookingStart;
});
print('${newBooking?.toJson()} has been uploaded');
if (widget.bookingPage != null) {
widget.bookingPage?.call();
}
}