HostServiceApi class
API for Host Service operations (Dart -> native).
Lets the app register named host functions that journey JavaScript can call
via await HostService.invokeFunction(name, args, callbacks). Registration
installs a native shim under name; when the shim is invoked it forwards the
call to Dart through HostFunctionCallbackApi, and Dart completes the call by
calling resolveCall/rejectCall (and streams values with invokeCallback).
Constructors
- HostServiceApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
-
Constructor for HostServiceApi. The
binaryMessengernamed argument is available for dependency injection. If it is left null, the default BinaryMessenger will be used which routes to the host platform.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- pigeonVar_binaryMessenger → BinaryMessenger?
-
final
- pigeonVar_messageChannelSuffix → String
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancelAllFunctions(
String reason) → Future< void> -
Reject all in-flight host-function calls with
reason. -
invokeCallback(
String callId, String callbackName, String? valueJson) → Future< void> -
Fire a script-supplied callback for an in-flight call.
valueJsonis a JSON-encoded value (or null). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerFunction(
String name) → Future< void> -
Register a native shim under
namewith the SDK's HostService. -
rejectCall(
String callId, String message) → Future< void> -
Reject an in-flight call with
message. -
resolveCall(
String callId, String? valueJson) → Future< void> -
Complete an in-flight call.
valueJsonis a JSON-encoded value (or null). -
toString(
) → String -
A string representation of this object.
inherited
-
unregisterFunction(
String name) → Future< void> - Remove a previously registered function; no-op if it is not present.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
pigeonChannelCodec
→ const MessageCodec<
Object?>