changes local

dev_v3.13.6_BLE_Faiz
Aamir Muhammad 2 years ago
parent 660ec3a207
commit e18ba6822a

@ -59,7 +59,7 @@ class AppointmentActions extends StatefulWidget {
class _AppointmentActionsState extends State<AppointmentActions> {
List<AppoDetailsButton> appoButtonsList = [];
static bool isHuawei = false;
late HmsApiAvailability hmsApiAvailability;
HmsApiAvailability hmsApiAvailability = HmsApiAvailability();
@override
void initState() {

@ -1,17 +1,19 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:ui';
import 'package:device_calendar/device_calendar.dart';
import 'package:manage_calendar_events/manage_calendar_events.dart' as mcn;
import 'package:manage_calendar_events/manage_calendar_events.dart' as ios;
final DeviceCalendarPlugin deviceCalendarPlugin = DeviceCalendarPlugin();
final mcn.CalendarPlugin _myPlugin = mcn.CalendarPlugin();
final ios.CalendarPlugin _myPlugin = ios.CalendarPlugin();
class CalendarUtils {
static Completer<CalendarUtils>? _completer;
mcn.Calendar? get writableCalendars => calendars.firstWhere((c) => !c.isReadOnly!);
List<mcn.Calendar> calendars;
dynamic get writableCalendars => calendars.firstWhere((c) => !c.isReadOnly!);
dynamic calendars;
CalendarUtils._(this.calendars);
@ -21,9 +23,15 @@ class CalendarUtils {
if (_completer == null) {
_completer = await Completer<CalendarUtils>();
try {
final List<mcn.Calendar>? calendarsResult = await _myPlugin.getCalendars();
// if (calendarsResult.data != null)
_completer?.complete(await CalendarUtils._(await calendarsResult!));
final dynamic calendarsResult;
if (Platform.isIOS) {
calendarsResult = await _myPlugin.getCalendars();
_completer?.complete(await CalendarUtils._(await calendarsResult!));
} else {
calendarsResult = await deviceCalendarPlugin.retrieveCalendars();
print(jsonEncode(calendarsResult.data!));
_completer?.complete(await CalendarUtils._(await calendarsResult.data!));
}
} on Exception catch (e) {
_completer!.completeError(e);
final Future<CalendarUtils> sharedPrefsFuture = _completer!.future;
@ -31,6 +39,7 @@ class CalendarUtils {
return sharedPrefsFuture;
}
}
return _completer!.future;
}
@ -78,11 +87,18 @@ class CalendarUtils {
TZDateTime scheduleDateTimeUTZ = TZDateTime.from(scheduleDateTime!, _currentLocation);
// print("eventId: " + eventId);
print("eventId: " + "hhgvhg");
// print("writableCalendars-name: " + writableCalendars.name);
// print("writableCalendars-Id: " + writableCalendars.id);
// print("writableCalendarsToString: " + writableCalendars.toString());
Event event = Event(writableCalendars!.id, start: scheduleDateTimeUTZ, end: scheduleDateTimeUTZ.add(Duration(minutes: 30)), title: title, description: description);
print("writableCalendarsToString: " + writableCalendars.toString());
print("writableCalendarsToString: " + writableCalendars!.id!);
Event event = await Event(
writableCalendars!.id,
start: scheduleDateTimeUTZ,
end: scheduleDateTimeUTZ.add(Duration(minutes: 30)),
title: title,
description: description,
);
deviceCalendarPlugin.createOrUpdateEvent(event).catchError((e) {
print("catchError " + e.toString());
}).whenComplete(() {
@ -90,8 +106,12 @@ class CalendarUtils {
});
}
deleteEvent(mcn.Calendar _calendar, Event _event) async {
await deviceCalendarPlugin.deleteEvent(_calendar.id, _event.eventId);
deleteEvent(Calendar _calendar, Event _event) async {
if (Platform.isIOS) {
await _myPlugin.deleteEvent(calendarId: _calendar.id!, eventId: _event.eventId!);
} else {
await deviceCalendarPlugin.deleteEvent(_calendar.id, _event.eventId);
}
}
Future retrieveEvents(

Loading…
Cancel
Save