Flutter Engine
FlutterMethodChannel Class Reference

#import <FlutterChannels.h>

Inheritance diagram for FlutterMethodChannel:

Instance Methods

(instancetype) - initWithName:binaryMessenger:codec:
 
(void) - invokeMethod:arguments:
 
(void) - invokeMethod:arguments:result:
 
(void) - setMethodCallHandler:
 
(void) - resizeChannelBuffer:
 

Class Methods

(instancetype) + methodChannelWithName:binaryMessenger:
 
(instancetype) + methodChannelWithName:binaryMessenger:codec:
 

Detailed Description

A channel for communicating with the Flutter side using invocation of asynchronous methods.

Definition at line 161 of file FlutterChannels.h.

Method Documentation

◆ initWithName:binaryMessenger:codec:()

- (instancetype) initWithName: (NSString*)  name
binaryMessenger: (NSObject<FlutterBinaryMessenger>*)  messenger
codec: (NSObject<FlutterMethodCodec>*)  codec 

Initializes a FlutterMethodChannel with the specified name, binary messenger, and method codec.

The channel name logically identifies the channel; identically named channels interfere with each other's communication.

The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by FlutterEngine and FlutterViewController.

Parameters
nameThe channel name.
messengerThe binary messenger.
codecThe method codec.

Definition at line 193 of file FlutterChannels.mm.

References _codec, _connection, _name, FlutterBinaryReply, FlutterMethodNotImplemented, id, and FlutterMethodCall::methodCallWithMethodName:arguments:.

193  :(NSString*)name
194  binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
195  codec:(NSObject<FlutterMethodCodec>*)codec {
196  self = [super init];
197  NSAssert(self, @"Super init cannot be nil");
198  _name = [name retain];
199  _messenger = [messenger retain];
200  _codec = [codec retain];
201  return self;
202 }
NSString * _name
const char * name
Definition: fuchsia.cc:50
NSObject< FlutterMessageCodec > * _codec

◆ invokeMethod:arguments:()

- (void) invokeMethod: (NSString *)  method
arguments: (id _Nullable)  arguments 

Invokes the specified Flutter method with the specified arguments, expecting no results.

See also
MethodChannel.setMethodCallHandler
Parameters
methodThe name of the method to invoke.
argumentsThe arguments. Must be a value supported by the codec of this channel.

◆ invokeMethod:arguments:result:()

- (void) invokeMethod: (NSString *)  method
arguments: (id _Nullable)  arguments
result: (FlutterResult _Nullable)  callback 

Invokes the specified Flutter method with the specified arguments, expecting an asynchronous result.

Parameters
methodThe name of the method to invoke.
argumentsThe arguments. Must be a value supported by the codec of this channel.
callbackA callback that will be invoked with the asynchronous result. The result will be a FlutterError instance, if the method call resulted in an error on the Flutter side. Will be FlutterMethodNotImplemented, if the method called was not implemented on the Flutter side. Any other value, including nil, should be interpreted as successful results.

◆ methodChannelWithName:binaryMessenger:()

+ (instancetype) methodChannelWithName: (NSString*)  name
binaryMessenger: (NSObject<FlutterBinaryMessenger>*)  messenger 

Creates a FlutterMethodChannel with the specified name and binary messenger.

The channel name logically identifies the channel; identically named channels interfere with each other's communication.

The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by FlutterEngine and FlutterViewController.

The channel uses FlutterStandardMethodCodec to encode and decode method calls and result envelopes.

Parameters
nameThe channel name.
messengerThe binary messenger.

Definition at line 180 of file FlutterChannels.mm.

References methodChannelWithName:binaryMessenger:codec:.

180  :(NSString*)name
181  binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger {
182  NSObject<FlutterMethodCodec>* codec = [FlutterStandardMethodCodec sharedInstance];
183  return [FlutterMethodChannel methodChannelWithName:name binaryMessenger:messenger codec:codec];
184 }
instancetype methodChannelWithName:binaryMessenger:codec:(NSString *name, [binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger, [codec] NSObject< FlutterMethodCodec > *codec)
const char * name
Definition: fuchsia.cc:50

◆ methodChannelWithName:binaryMessenger:codec:()

+ (instancetype) methodChannelWithName: (NSString*)  name
binaryMessenger: (NSObject<FlutterBinaryMessenger>*)  messenger
codec: (NSObject<FlutterMethodCodec>*)  codec 

Creates a FlutterMethodChannel with the specified name, binary messenger, and method codec.

The channel name logically identifies the channel; identically named channels interfere with each other's communication.

The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by FlutterEngine and FlutterViewController.

Parameters
nameThe channel name.
messengerThe binary messenger.
codecThe method codec.

Definition at line 186 of file FlutterChannels.mm.

Referenced by FlutterViewController::initWithProject:, FlutterEngine::initWithScenario:withCompletion:, FlutterTextInputPlugin::initWithViewController:, and methodChannelWithName:binaryMessenger:.

186  :(NSString*)name
187  binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
188  codec:(NSObject<FlutterMethodCodec>*)codec {
189  return [[[FlutterMethodChannel alloc] initWithName:name binaryMessenger:messenger
190  codec:codec] autorelease];
191 }
const char * name
Definition: fuchsia.cc:50

◆ resizeChannelBuffer:()

- (void) resizeChannelBuffer: (NSInteger)  newSize

Adjusts the number of messages that will get buffered when sending messages to channels that aren't fully setup yet. For example, the engine isn't running yet or the channel's message handler isn't setup on the Dart side yet.

Definition at line 256 of file FlutterChannels.mm.

References _name, and ResizeChannelBuffer().

256  :(NSInteger)newSize {
257  ResizeChannelBuffer(_messenger, _name, newSize);
258 }
static void ResizeChannelBuffer(NSObject< FlutterBinaryMessenger > *binaryMessenger, NSString *channel, NSInteger newSize)
NSString * _name

◆ setMethodCallHandler:()

- (void) setMethodCallHandler: (FlutterMethodCallHandler _Nullable)  handler

Registers a handler for method calls from the Flutter side.

Replaces any existing handler. Use a nil handler for unregistering the existing handler.

Parameters
handlerThe method call handler.

The documentation for this class was generated from the following files: