# FlutterPlugin

Objective-C

    @protocol FlutterPlugin <NSObject, FlutterApplicationLifeCycleDelegate>

Swift

    protocol FlutterPlugin : FlutterApplicationLifeCycleDelegate

Implemented by the iOS part of a Flutter plugin.

Defines a set of optional callback methods and a method to set up the plugin and register it to be called by other application components.

- `+registerWithRegistrar:`

  Registers this plugin using the context information and callback registration methods exposed by the given registrar.

  The registrar is obtained from a `FlutterPluginRegistry` which keeps track of the identity of registered plugins and provides basic support for cross-plugin coordination.

  The caller of this method, a plugin registrant, is usually autogenerated by Flutter tooling based on declared plugin dependencies. The generated registrant asks the registry for a registrar for each plugin, and calls this method to allow the plugin to initialize itself and register callbacks with application objects available through the registrar protocol.

  #### Declaration

  Objective-C

      + (void)registerWithRegistrar:
          (nonnull NSObject<FlutterPluginRegistrar> *)registrar;

  Swift

      static func register(with registrar: FlutterPluginRegistrar)

  #### Parameters

  `registrar` | A helper providing application context and methods for registering callbacks.

- `+setPluginRegistrantCallback:`

  Set a callback for registering plugins to an additional `FlutterPluginRegistry`, including headless `FlutterEngine` instances.

  This method is typically called from within an application’s `AppDelegate` at startup to allow for plugins which create additional `FlutterEngine` instances to register the application’s plugins.

  #### Declaration

  Objective-C

      + (void)setPluginRegistrantCallback:
          (nonnull FlutterPluginRegistrantCallback)callback;

  Swift

      optional static func setPluginRegistrantCallback(_ callback: FlutterPluginRegistrantCallback)

  #### Parameters

  `callback` | A callback for registering some set of plugins with a `FlutterPluginRegistry`.

- `-handleMethodCall:result:`

  Called if this plugin has been registered to receive `FlutterMethodCall`s.

  #### Declaration

  Objective-C

      - (void)handleMethodCall:(nonnull FlutterMethodCall *)call
                        result:(nonnull FlutterResult)result;

  Swift

      optional func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult)

  #### Parameters

  `call` | The method call command object.
  `result` | A callback for submitting the result of the call.

- `-detachFromEngineForRegistrar:`

  Called when a plugin is being removed from a `FlutterEngine`, which is usually the result of the `FlutterEngine` being deallocated. This method provides the opportunity to do necessary cleanup.

  You will only receive this method if you registered your plugin instance with the `FlutterEngine` via `-[FlutterPluginRegistry publish:]`.

  #### Declaration

  Objective-C

      - (void)detachFromEngineForRegistrar:
          (nonnull NSObject<FlutterPluginRegistrar> *)registrar;

  Swift

      optional func detachFromEngine(for registrar: FlutterPluginRegistrar)

  #### Parameters

  `registrar` | The registrar that was used to publish the plugin.

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

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