plus_plugins
plus_plugins copied to clipboard
Doesnt support other plugins in Alarm manager?
i dont know this is an issue or bug.So im writing it.I wrote an alarm manager function to execute certain task periodically.its firing periodically.But the problem is i cant use certain plugin inside that .I used shared preference plugin to take some date from locally.But alarm manager function return null on that.I dont know why.its only happens inside that Alarm manager static function.I just used another plugin Getstorage to do the similar thing again.But result was similar. In my case i am just tryin to build a wallpaper App.I just wanna change wallpaper periodically.There are numerous categories like nature,bike,car etc. for selection.If user select one category.Then i just fired an alarm mnager and should have to do automatically change wallpaper according to the category.Due to the static function of alarm manager, for knowing selected category i just wrote those to the locally.So for grabbing it in alarm manager static function, im used shared preferebce and Getstorage plugins.But both of them canot works as expected in alarm manager.I dont know why.Is this a bug or is this due to static function of alarm manager? Is there any solution or is there any idea to overcome it.
I have tried many ways to make things work correctly but all them has failed...
I've declared a global SharedPrerences (out of any scope) and call sharedpreferences.setString() to write a value to storage inside my function called periodically by android_alarm_manager_plus.
setString return true, telling me that the value has been stored !
In the main isolate, my app is returning null when I attempt read the value from sharedpreferences.
I don't understand why my function fired by the plugin, isn't saving the value...
@chazgps i dont know why this happens.may be this is due to static functionality of alaram manager.Any way, have to do some stuffs using method channel to implement this.I triedwith different plugins.They all have same results.They only executes pure dart codes,not all the flutter plugins.
My workaround was using IsolateNameServer.registerPortWithName in main isolate to register a named port. Then, in alarm isolate, i'm using IsolateNameServer.lookupPortByName to find this port and send the results to main isolate to be saved by SharedPreferences.
At the very least, we need better documentation for applying isolate in this situation.
This is caused by this issue https://github.com/flutter/flutter/issues/98473#issuecomment-1041895729
You can also find a workaround there.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days