AppClient class
This is the interface you can use everywhere in your application to communicate with foreground-service from application side. like start the service, stop it, listen for ServiceData updates etc.
note that you cannot use class inside serviceMain
function inside lib/main.dart
since that is the function that runs
inside foreground-service. to controll the foreground-service from service side meaning inside serviceMain
function use ServiceClient class
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- channel → MethodChannel
-
final
-
updates
→ Stream<
Map< String, dynamic> ?> -
listen for ServiceData updates from foreground service
no setter
Static Methods
-
execute(
ServiceData initialData) → Future< Map< String, dynamic> > -
start the foreground-service and runs the code you wrote in
serviceMain
function inlib/main.dart
and passes theinitialData
as the argument that is received in the execution callback you set in ServiceClient -
getData(
) → Future< Map< String, dynamic> ?> - returns the current ServiceData object from foreground-service
-
stopService(
) → Future< void> - orders foreground-service to stop