• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #import <Cocoa/Cocoa.h>
6 
7 #import "FlutterPluginMacOS.h"
8 
9 #import "FlutterBinaryMessenger.h"
10 #import "FlutterChannels.h"
11 #import "FlutterMacros.h"
12 
13 // TODO: Merge this file and FlutterPluginMacOS.h with the iOS FlutterPlugin.h, sharing all but
14 // the platform-specific methods.
15 
16 /**
17  * The protocol for an object managing registration for a plugin. It provides access to application
18  * context, as as allowing registering for callbacks for handling various conditions.
19  *
20  * Currently the macOS PluginRegistrar has very limited functionality, but is expected to expand
21  * over time to more closely match the functionality of FlutterPluginRegistrar.
22  */
23 FLUTTER_EXPORT
24 @protocol FlutterPluginRegistrar <NSObject>
25 
26 /**
27  * The binary messenger used for creating channels to communicate with the Flutter engine.
28  */
29 @property(nonnull, readonly) id<FlutterBinaryMessenger> messenger;
30 
31 /**
32  * The view displaying Flutter content. May return |nil|, for instance in a headless environment.
33  *
34  * WARNING: If/when multiple Flutter views within the same application are supported (#30701), this
35  * API will change.
36  */
37 @property(nullable, readonly) NSView* view;
38 
39 /**
40  * Registers |delegate| to receive handleMethodCall:result: callbacks for the given |channel|.
41  */
42 - (void)addMethodCallDelegate:(nonnull id<FlutterPlugin>)delegate
43                       channel:(nonnull FlutterMethodChannel*)channel;
44 
45 @end
46 
47 /**
48  * A registry of Flutter macOS plugins.
49  *
50  * Plugins are identified by unique string keys, typically the name of the
51  * plugin's main class.
52  *
53  * Plugins typically need contextual information and the ability to register
54  * callbacks for various application events. To keep the API of the registry
55  * focused, these facilities are not provided directly by the registry, but by
56  * a `FlutterPluginRegistrar`, created by the registry in exchange for the unique
57  * key of the plugin.
58  *
59  * There is no implied connection between the registry and the registrar.
60  * Specifically, callbacks registered by the plugin via the registrar may be
61  * relayed directly to the underlying iOS application objects.
62  */
63 @protocol FlutterPluginRegistry <NSObject>
64 
65 /**
66  * Returns a registrar for registering a plugin.
67  *
68  * @param pluginKey The unique key identifying the plugin.
69  */
70 - (nonnull id<FlutterPluginRegistrar>)registrarForPlugin:(nonnull NSString*)pluginKey;
71 
72 @end
73