A named channel for communicating with the Flutter application using asynchronous method calls.
Incoming method calls are decoded from binary on receipt, and Java results are encoded into binary before being transmitted back to Flutter. The MethodCodec
used must be compatible with the one used by the Flutter application. This can be achieved by creating a MethodChannel counterpart of this channel on the Dart side. The Java type of method call arguments and results is Object
, but only values supported by the specified MethodCodec
can be used.
The logical identity of the channel is given by its name. Identically named channels will interfere with each other's communication.
Nested Classes
static interface
A handler of incoming method calls.
static interface
Method call result callback.
Constructors
void
Invokes a method on this channel, expecting no result.
void
Invokes a method on this channel, optionally expecting a result.
void
Adjusts the number of messages that will get buffered when sending messages to channels that aren't fully set up yet.
void
Registers a method call handler on this channel.
void
Toggles whether the channel should show warning messages when discarding messages due to overflow.
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
messenger
- a BinaryMessenger
.
name
- a channel name String.
messenger
- a BinaryMessenger
.
name
- a channel name String.
codec
- a MessageCodec
.
messenger
- a BinaryMessenger
.
name
- a channel name String.
codec
- a MessageCodec
.
taskQueue
- a BinaryMessenger.TaskQueue
that specifies what thread will execute the handler. Specifying null means execute on the platform thread. See also BinaryMessenger.makeBackgroundTaskQueue()
.
Invokes a method on this channel, expecting no result.
method
- the name String of the method.
arguments
- the arguments for the invocation, possibly null.
Any uncaught exception thrown by the result callback will be caught and logged.
method
- the name String of the method.
arguments
- the arguments for the invocation, possibly null.
callback
- a MethodChannel.Result
callback for the invocation result, or null.
Registers a method call handler on this channel.
Overrides any existing handler registration for (the name of) this channel.
If no handler has been registered, any incoming method call on this channel will be handled silently by sending a null reply. This results in a MissingPluginException on the Dart side, unless an OptionalMethodChannel is used.
handler
- a MethodChannel.MethodCallHandler
, or null to deregister.
public void resizeChannelBuffer(int newSize)
Adjusts the number of messages that will get buffered when sending messages to channels that aren't fully set up yet. For example, the engine isn't running yet or the channel's message handler isn't set up on the Dart side yet.
public void setWarnsOnChannelOverflow(boolean warns)
Toggles whether the channel should show warning messages when discarding messages due to overflow. When 'warns' is false the channel is expected to overflow and warning messages will not be shown.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4