AsynchronousMethodChannel class

A named channel which supports asynchronous return results for communicating with the Flutter application using asynchronous method calls.

Method calls are encoded into binary before being sent, and binary results received are decoded into Dart values. The MethodCodec used must be compatible with the one used by the platform plugin. This can be achieved by creating a method channel counterpart of this channel on the platform side. The Dart type of arguments and results is dynamic, but only values supported by the specified MethodCodec can be used. The use of unsupported values should be considered programming errors, and will result in exceptions being thrown. The null value is supported for all codecs.

The logical identity of the channel is given by its name. Identically named channels will interfere with each other's communication.

See: flutter.dev/platform-channels/

Implemented types

Constructors

AsynchronousMethodChannel(String name, [MethodCodec codec = const StandardMethodCodec(), BinaryMessenger? binaryMessenger])
Creates a AsynchronousMethodChannel with the specified name.

Properties

binaryMessenger BinaryMessenger
The messenger used by this channel to send platform messages.
no setteroverride
codec MethodCodec
The message codec used by this channel, not null.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
name String
The logical channel on which communication happens, not null.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkMethodCallHandler(Future? handler(MethodCall call)?) bool
checkMockMethodCallHandler(Future? handler(MethodCall call)?) bool
invokeAsynchronousMethod<T>(String method, [dynamic arguments]) Future<T>
Invokes an asynchronous method on this channel with the specified arguments.
invokeListMethod<T>(String method, [dynamic arguments]) Future<List<T>>
An implementation of invokeMethod that can return typed lists.
override
invokeMapMethod<K, V>(String method, [dynamic arguments]) Future<Map<K, V>>
An implementation of invokeMethod that can return typed maps.
override
invokeMethod<T>(String method, [dynamic arguments]) Future<T>
Invokes a method on this channel with the specified arguments.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setMethodCallHandler(Future handler(MethodCall call)?) → void
Sets a callback for receiving method calls on this channel.
override
setMockAsynchronousMethodCallHandler(Future handler(MethodCall call, MockResult? result)) → void
Sets a mock callback for intercepting method invocations on this channel.
setMockMethodCallHandler(Future? handler(MethodCall call)?) → void
Use setMockAsynchronousMethodCallHandler instead of setMockMethodCallHandler.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

generateId() String
Generate a unique id.

Constants

DEBUG → const bool
TAG → const String
timeout → const int