SayWut / flutter_foreground_service_plugin

MIT License
12 stars 12 forks source link

Starting Background task #10

Open Samson11 opened 3 years ago

Samson11 commented 3 years ago

When i try to use the example to change notification content. I get this error.

E/flutter (21734): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The method 'toRawHandle' was called on null.

E/flutter (21734): Tried calling: toRawHandle() E/flutter (21734): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5) E/flutter (21734): #1 FlutterForegroundServicePlugin.startPeriodicTask (package:flutter_foreground_service_plugin/flutter_foreground_service_plugin.dart:162:60)

PoloLacoste commented 3 years ago

When you start periodic task with startPeriodicTask you must pass a top-level function to the parameter periodicTaskFun.

Top-level function : A function defined outside of any class, object, or interface.

darshansatra1 commented 3 years ago

Convert your function to static and it will work