From ff7ab84650430b643d7fdafffa78f945a7894715 Mon Sep 17 00:00:00 2001 From: WaseemAbbasi22 Date: Mon, 9 Dec 2024 17:13:59 +0300 Subject: [PATCH] calander implementation inprogress --- .../utilities/service_request_utils.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/service_request_latest/utilities/service_request_utils.dart b/lib/service_request_latest/utilities/service_request_utils.dart index 77f96983..ada3ad45 100644 --- a/lib/service_request_latest/utilities/service_request_utils.dart +++ b/lib/service_request_latest/utilities/service_request_utils.dart @@ -121,16 +121,14 @@ class ServiceRequestUtils { var currentLocation = getLocation(await FlutterTimezone.getLocalTimezone()); final calendarsResult = await DeviceCalendarPlugin().retrieveCalendars(); - calendarsResult.data?.forEach((element){ - print('calander element are ${element.toJson()}'); - }); + if (calendarsResult.data?.isNotEmpty ?? false) { setLocalLocation(currentLocation); await Future.delayed(const Duration(seconds: 2)); TZDateTime startDate = TZDateTime.from(start, currentLocation); TZDateTime endDate = TZDateTime.from(end, currentLocation); final calendarId = calendarsResult.data!.first.id; // Use the first calendar - print('calander id i got is ${calendarId}'); + var eventToCreate = Event( calendarId, eventId: requestId.toString(), @@ -139,11 +137,9 @@ class ServiceRequestUtils { start: startDate, end: endDate, ); - print('calander event to add is ${eventToCreate.toJson()}'); final response = await DeviceCalendarPlugin().createOrUpdateEvent(eventToCreate); print("Response of adding calendar is ${response?.data}"); } else { - print("No calendars available on the device."); // "No calendars available on the device.".showToast(); }