Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_HEADERS_FLUTTERPLUGINREGISTRARMACOS_H_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_HEADERS_FLUTTERPLUGINREGISTRARMACOS_H_
7
8#import <Cocoa/Cocoa.h>
9
11#import "FlutterChannels.h"
12#import "FlutterMacros.h"
15#import "FlutterTexture.h"
16
17// TODO(stuartmorgan): Merge this file and FlutterPluginMacOS.h with the iOS FlutterPlugin.h,
18// sharing all but the platform-specific methods.
19
20/**
21 * The protocol for an object managing registration for a plugin. It provides access to application
22 * context, as allowing registering for callbacks for handling various conditions.
23 *
24 * Currently the macOS PluginRegistrar has very limited functionality, but is expected to expand
25 * over time to more closely match the functionality of FlutterPluginRegistrar.
26 */
28@protocol FlutterPluginRegistrar <NSObject>
29
30/**
31 * The binary messenger used for creating channels to communicate with the Flutter engine.
32 */
33@property(nonnull, readonly) id<FlutterBinaryMessenger> messenger;
34
35/**
36 * Returns a `FlutterTextureRegistry` for registering textures
37 * provided by the plugin.
38 */
39@property(nonnull, readonly) id<FlutterTextureRegistry> textures;
40
41/**
42 * The view displaying Flutter content.
43 *
44 * This property is provided for backwards compatibility for apps
45 * that assume a single view. This will eventually be replaced by
46 * a multi-view API variant.
47 *
48 * This method may return |nil|, for instance in a headless environment.
49 */
50@property(nullable, readonly) NSView* view;
51
52/**
53 * Registers |delegate| to receive handleMethodCall:result: callbacks for the given |channel|.
54 */
55- (void)addMethodCallDelegate:(nonnull id<FlutterPlugin>)delegate
56 channel:(nonnull FlutterMethodChannel*)channel;
57
58/**
59 * Registers the plugin as a receiver of `NSApplicationDelegate` calls.
60 *
61 * @param delegate The receiving object, such as the plugin's main class.
62 */
63- (void)addApplicationDelegate:(nonnull NSObject<FlutterAppLifecycleDelegate>*)delegate;
64
65/**
66 * Registers a `FlutterPlatformViewFactory` for creation of platform views.
67 *
68 * Plugins expose `NSView` for embedding in Flutter apps by registering a view factory.
69 *
70 * @param factory The view factory that will be registered.
71 * @param factoryId A unique identifier for the factory, the Dart code of the Flutter app can use
72 * this identifier to request creation of a `NSView` by the registered factory.
73 */
74- (void)registerViewFactory:(nonnull NSObject<FlutterPlatformViewFactory>*)factory
75 withId:(nonnull NSString*)factoryId;
76
77/**
78 * Publishes a value for external use of the plugin.
79 *
80 * Plugins may publish a single value, such as an instance of the
81 * plugin's main class, for situations where external control or
82 * interaction is needed.
83 *
84 * The published value will be available from the `FlutterPluginRegistry`.
85 * Repeated calls overwrite any previous publication.
86 *
87 * @param value The value to be published.
88 */
89- (void)publish:(nonnull NSObject*)value;
90
91/**
92 * Returns the file name for the given asset.
93 * The returned file name can be used to access the asset in the application's main bundle.
94 *
95 * @param asset The name of the asset. The name can be hierarchical.
96 * @return the file name to be used for lookup in the main bundle.
97 */
98- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset;
99
100/**
101 * Returns the file name for the given asset which originates from the specified package.
102 * The returned file name can be used to access the asset in the application's main bundle.
103 *
104 *
105 * @param asset The name of the asset. The name can be hierarchical.
106 * @param package The name of the package from which the asset originates.
107 * @return the file name to be used for lookup in the main bundle.
108 */
109- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset
110 fromPackage:(nonnull NSString*)package;
111
112@end
113
114/**
115 * A registry of Flutter macOS plugins.
116 *
117 * Plugins are identified by unique string keys, typically the name of the
118 * plugin's main class.
119 *
120 * Plugins typically need contextual information and the ability to register
121 * callbacks for various application events. To keep the API of the registry
122 * focused, these facilities are not provided directly by the registry, but by
123 * a `FlutterPluginRegistrar`, created by the registry in exchange for the unique
124 * key of the plugin.
125 *
126 * There is no implied connection between the registry and the registrar.
127 * Specifically, callbacks registered by the plugin via the registrar may be
128 * relayed directly to the underlying iOS application objects.
129 */
130@protocol FlutterPluginRegistry <NSObject>
131
132/**
133 * Returns a registrar for registering a plugin.
134 *
135 * @param pluginKey The unique key identifying the plugin.
136 */
137- (nonnull id<FlutterPluginRegistrar>)registrarForPlugin:(nonnull NSString*)pluginKey;
138
139/**
140 * Returns a value published by the specified plugin.
141 *
142 * @param pluginKey The unique key identifying the plugin.
143 * @return An object published by the plugin, if any. Will be `NSNull` if
144 * nothing has been published. Will be `nil` if the plugin has not been
145 * registered.
146 */
147- (nullable NSObject*)valuePublishedByPlugin:(nonnull NSString*)pluginKey;
148
149@end
150
151#endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_HEADERS_FLUTTERPLUGINREGISTRARMACOS_H_
#define FLUTTER_DARWIN_EXPORT
std::vector< std::shared_ptr< FakeTexture > > textures
HWND(* FlutterPlatformViewFactory)(const FlutterPlatformViewCreationParameters *)
const uintptr_t id