Search code examples
flutterdartflutter-layoutandroid-alarmsbadge

How to update badge count with android alarm manager which calls a function


I have a problem. I have an alarm manager which triggers a function static Future<void> callback() async but I would like to update my IconBadge every time this function is triggered so that it always goes up one number. I tried it with setState in the function, but this doesn't work because the function has to be static. My error when i use setState in the function: Instance members can't be accessed from a static method. Try removing the reference to the instance member, or removing the keyword 'static' from the method.

What is the best way to solve my problem?


Solution

  • Hello you can use something like Isolate to increment the counter.