builttoroam / device_calendar

A cross platform plugin for modifying calendars on the user's device
https://pub.dev/packages/device_calendar
BSD 3-Clause "New" or "Revised" License
259 stars 258 forks source link

Don't create any calendar when calling the instance of the plugin #493

Open milindgoel15 opened 11 months ago

milindgoel15 commented 11 months ago

Describe the bug

When we use the plugin without providing any calendar names, id, etc, and call the plugin from a simple button to get the list of calendars on the device. It also creates another calendar under the default name and properties.

                        final deviceCalendarPlugin = DeviceCalendarPlugin();
                        final result =
                            await deviceCalendarPlugin.retrieveCalendars();
                        print(result.data!.map((e) {
                          print(e.accountName);
                          print(e.id);
                        }));

To delete this calendar, we call the function deleteCalendar with its id which successfully deletes it.

                        final deleted =
                            await deviceCalendarPlugin.deleteCalendar("16");
             print(deleted.data);

But it gets created again a few min later under a new id making it impossible to delete it for good.

To Reproduce Steps to reproduce the behavior:

  1. Create an instance of the plugin on a button
  2. run the button
  3. A calendar with default properties gets created

Expected behavior Please change this behaviour to not create a calendar when a user is only calling the plugin to retrieve or delete functions or any other function that does not involve creating any calendar. Only create calendars when using createCalendar function.

Screenshots Screenshot_2023-07-18-16-13-22-008_com.google.android.calendar~01.jpg

Device(s) tested This can be very important as not all device vendors do calendar in the same way.

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.22621.1992], locale en-IN)
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Android Studio (version 2022.2)
[✓] VS Code, 64-bit edition (version 1.80.1)
[✓] Connected device (1 available)
[✓] Network resources

• No issues found!

Additional context full code with button:

                    TextButton(
                      onPressed: () async {
                        final deviceCalendarPlugin = DeviceCalendarPlugin();

                        final deleted =
                            await deviceCalendarPlugin.deleteCalendar("16");

                        final result =
                            await deviceCalendarPlugin.retrieveCalendars();
                        print(result.data!.map((e) {
                          print(e.accountName);
                          print(e.id);
                        }));
                        print(deleted.data);
                      },
                      child: const Text(
                        "delete Calendar",
                        style: TextStyle(
                          fontSize: 18,
                        ),
                      ),
                    )