Flutter Engine
FlutterPluginRegistrarMacOS.h
Go to the documentation of this file.
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 
8 #import "FlutterChannels.h"
9 #import "FlutterMacros.h"
10 #import "FlutterPluginMacOS.h"
11 #import "FlutterTexture.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  */
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  * Returns a `FlutterTextureRegistry` for registering textures
33  * provided by the plugin.
34  */
35 @property(nonnull, readonly) id<FlutterTextureRegistry> textures;
36 
37 /**
38  * The view displaying Flutter content. May return |nil|, for instance in a headless environment.
39  *
40  * WARNING: If/when multiple Flutter views within the same application are supported (#30701), this
41  * API will change.
42  */
43 @property(nullable, readonly) NSView* view;
44 
45 /**
46  * Registers |delegate| to receive handleMethodCall:result: callbacks for the given |channel|.
47  */
48 - (void)addMethodCallDelegate:(nonnull id<FlutterPlugin>)delegate
49  channel:(nonnull FlutterMethodChannel*)channel;
50 
51 @end
52 
53 /**
54  * A registry of Flutter macOS plugins.
55  *
56  * Plugins are identified by unique string keys, typically the name of the
57  * plugin's main class.
58  *
59  * Plugins typically need contextual information and the ability to register
60  * callbacks for various application events. To keep the API of the registry
61  * focused, these facilities are not provided directly by the registry, but by
62  * a `FlutterPluginRegistrar`, created by the registry in exchange for the unique
63  * key of the plugin.
64  *
65  * There is no implied connection between the registry and the registrar.
66  * Specifically, callbacks registered by the plugin via the registrar may be
67  * relayed directly to the underlying iOS application objects.
68  */
69 @protocol FlutterPluginRegistry <NSObject>
70 
71 /**
72  * Returns a registrar for registering a plugin.
73  *
74  * @param pluginKey The unique key identifying the plugin.
75  */
76 - (nonnull id<FlutterPluginRegistrar>)registrarForPlugin:(nonnull NSString*)pluginKey;
77 
78 @end
int32_t id
#define FLUTTER_EXPORT