Im building an appointment app in flutter for ios and android, im using Google Calendar’s api for that, im trying to use the new feature of calendar,bookable appointment schedule in order to do that, but i cant manage, to get the this event via code.
// Get all available hours from the appointment schedule event of the selected date
Future<List<String>> getAllAvailableHours(DateTime selectedDate) async {
print('Fetching available hours for date: $selectedDate');
try {
// Authenticate client
final client = await _getClient();
// we have a right client creds
// Initialize Calendar API
final calendarApi = calendar.CalendarApi(client);
print('calendarApi : $calendarApi');
// Define start and end time for the selected day
DateTime startTime = DateTime(selectedDate.year, selectedDate.month, selectedDate.day, 0, 0, 0);
DateTime endTime = DateTime(selectedDate.year, selectedDate.month, selectedDate.day, 23, 59, 59);
print('Start Time Is: $startTime');
print('endTime Is: $endTime');
// Fetch events from Google Calendar
final events = await calendarApi.events.list(_calendarId, timeMin: startTime.toUtc(), timeMax: endTime.toUtc());
//return availableHours;
} catch (e) {
print('Error fetching available hours: $e');
rethrow;
}
}
google calendar api is already integrated even after multiple checkings, and i can get normal events, just not the new feature event the bookable appointment schedule.
liav bohadana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.