MethodChannel class

A named channel for communicating with platform plugins 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.


Implemented by


MethodChannel(String name, [ MethodCodec codec = const StandardMethodCodec() ])
Creates a MethodChannel with the specified name. [...]


codec MethodCodec
The message codec used by this channel, not null.
name → String
The logical channel on which communication happens, not null.
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited


invokeMethod(String method, [ dynamic arguments ]) → Future
Invokes a method on this channel with the specified arguments. [...]
setMethodCallHandler(Future handler(MethodCall call)) → void
Sets a callback for receiving method calls on this channel. [...]
setMockMethodCallHandler(Future handler(MethodCall call)) → void
Sets a mock callback for intercepting method invocations on this channel. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() → String
Returns a string representation of this object.


operator ==(dynamic other) → bool
The equality operator. [...]