fluttercommunity / flutter_workmanager

A Flutter plugin which allows you to execute code in the background on Android and iOS.
862 stars 277 forks source link

There is a problem that the calendar schedule that I read with device_calendar is not displayed, so I'm asking for help. #550

Closed nicelee777 closed 7 months ago

nicelee777 commented 7 months ago

In the home_widget API, I'm using workmanager to refresh the widget. The Home_widget reads data from a database (isar db) and displays schedules from the phone's calendar (using the device_calendar API). However, while the data from the database is displayed correctly, the schedules are not being shown. (The method works correctly when executed directly within the app.)

I would like to know under what circumstances this issue could occur, and how I could debug to check if the execution is functioning properly.


@pragma("vm:entry-point") void callbackDispatcher() { Workmanager().executeTask((taskName, inputData) async { debugPrint( 'JH: ${DateTime.now().toString()}, Workmanger Doing!!!!!!!!!!!!!!!!!'); CommonData.isWorkManager = true;

return Future.wait<bool?>([
  HomeWidgetCalendarMaker(44).sendAndUpdate(),
  HomeWidgetCalendarMaker(45).sendAndUpdate(),
  HomeWidgetCalendarMaker(55).sendAndUpdate(),
]).then((value) {
  return !value.contains(false);
});

}); }


Future<bool?> sendAndUpdate() async { try { // Ready to use await CommonData.init(); await WorktypeHelper().init(); await IsarHelper().initDB();

  await _imageMake(); // DB, get the schedule, draw the data imported to Canvas, and save it as an image file.(Prepare images for use in homewidget.)
  await _sendData(); //  Forwarding information (image) to the widget
  await _updateWidget(); // update widget

  return true;
} catch (e) {
  debugPrint(e.toString());
  return false;
}

}