# FlutterMethodChannel

Objective-C

    @interface FlutterMethodChannel : NSObject

Swift

    class FlutterMethodChannel : NSObject

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

- `+methodChannelWithName:binaryMessenger:`

  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.

  #### Declaration

  Objective-C

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

  Swift

      convenience init(name: String, binaryMessenger messenger: FlutterBinaryMessenger)

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.

- `+methodChannelWithName:binaryMessenger: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`.

  #### Declaration

  Objective-C

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

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.
  `codec` | The method codec.

- `-initWithName:binaryMessenger: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`.

  #### Declaration

  Objective-C

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

  Swift

      init(name: String, binaryMessenger messenger: FlutterBinaryMessenger, codec: FlutterMethodCodec & NSObjectProtocol)

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.
  `codec` | The method codec.

- `-initWithName:binaryMessenger:codec:taskQueue:`

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

  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`.

  #### Declaration

  Objective-C

      - (nonnull instancetype)
             initWithName:(nonnull NSString *)name
          binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger
                    codec:(nonnull NSObject<FlutterMethodCodec> *)codec
                taskQueue:(NSObject<FlutterTaskQueue> *_Nullable)taskQueue;

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.
  `codec` | The method codec.
  `taskQueue` | The FlutterTaskQueue that executes the handler (see -[FlutterBinaryMessenger makeBackgroundTaskQueue]).

- `-invokeMethod:arguments:`

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

  See

  MethodChannel.setMethodCallHandler

  #### Declaration

  Objective-C

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

  Swift

      func invokeMethod(_ method: String, arguments: Any?)

  #### Parameters

  `method` | The name of the method to invoke.
  `arguments` | The arguments. Must be a value supported by the codec of this channel.

- `-invokeMethod:arguments:result:`

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

  #### Declaration

  Objective-C

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

  Swift

      func invokeMethod(_ method: String, arguments: Any?, result callback: FlutterResult? = nil)

  #### Parameters

  `method` | The name of the method to invoke.
  `arguments` | The arguments. Must be a value supported by the codec of this channel.
  `callback` | A 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.

- `-setMethodCallHandler:`

  Registers a handler for method calls from the Flutter side.

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

  #### Declaration

  Objective-C

      - (void)setMethodCallHandler:(FlutterMethodCallHandler _Nullable)handler;

  Swift

      func setMethodCallHandler(_ handler: FlutterMethodCallHandler?)

  #### Parameters

  `handler` | The method call handler.

- `-resizeChannelBuffer:`

  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.

  #### Declaration

  Objective-C

      - (void)resizeChannelBuffer:(NSInteger)newSize;

  Swift

      func resizeBuffer(_ newSize: Int)

© 2023 Flutter. All rights reserved. (Last updated: 2023-03-28)

Generated by jazzy ♪♫ v0.14.3, a Realm project.