Flutter iOS Embedder
FlutterEngine_Internal.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_IOS_FRAMEWORK_SOURCE_FLUTTERENGINE_INTERNAL_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERENGINE_INTERNAL_H_
7 
11 
12 #include "flutter/fml/memory/weak_ptr.h"
13 #include "flutter/fml/task_runner.h"
14 #include "flutter/lib/ui/window/pointer_data_packet.h"
15 #include "flutter/lib/ui/window/viewport_metrics.h"
16 #include "flutter/shell/common/platform_view.h"
17 #include "flutter/shell/common/rasterizer.h"
18 #include "flutter/shell/common/shell.h"
19 
20 #include "flutter/shell/platform/embedder/embedder.h"
21 
32 
34 
36 
38 
39 // Indicates whether this engine has **ever** been manually registered to a scene.
40 @property(nonatomic, assign) BOOL manuallyRegisteredToScene;
41 
42 - (void)updateViewportMetrics:(flutter::ViewportMetrics)viewportMetrics;
43 - (void)dispatchPointerDataPacket:(std::unique_ptr<flutter::PointerDataPacket>)packet;
44 - (BOOL)platformViewShouldAcceptTouchAtTouchBeganLocation:(flutter::PointData)location
45  viewId:(uint64_t)viewId;
46 
47 - (void)installFirstFrameCallback:(void (^)(void))block;
48 - (void)enableSemantics:(BOOL)enabled withFlags:(int64_t)flags;
49 - (void)notifyViewCreated;
50 - (void)notifyViewDestroyed;
51 
52 - (flutter::Rasterizer::Screenshot)screenshot:(flutter::Rasterizer::ScreenshotType)type
53  base64Encode:(bool)base64Encode;
54 
55 - (FlutterPlatformPlugin*)platformPlugin;
58 - (FlutterEnginePluginSceneLifeCycleDelegate*)sceneLifeCycleDelegate;
59 - (void)launchEngine:(nullable NSString*)entrypoint
60  libraryURI:(nullable NSString*)libraryOrNil
61  entrypointArgs:(nullable NSArray<NSString*>*)entrypointArgs;
62 /**
63  * Creates the shell, adopting the calling thread as this engine's platform thread.
64  *
65  * Must be called on the main thread; see the `FlutterEngine` class documentation.
66  */
67 - (BOOL)createShell:(nullable NSString*)entrypoint
68  libraryURI:(nullable NSString*)libraryOrNil
69  initialRoute:(nullable NSString*)initialRoute NS_SWIFT_UI_ACTOR;
70 - (void)attachView;
71 - (void)notifyLowMemory;
72 
73 /// Asynchronously waits until the first frame is presented or the timeout is exceeded, then invokes
74 /// callback.
75 - (void)waitForFirstFrame:(NSTimeInterval)timeout callback:(void (^)(BOOL didTimeout))callback;
76 
77 /**
78  * Creates one running FlutterEngine from another, sharing components between them.
79  *
80  * This results in a faster creation time and a smaller memory footprint engine.
81  * This should only be called on a FlutterEngine that is running.
82  *
83  * The spawned engine shares this engine's task runners, so this must be called on this engine's
84  * platform thread, which is always the main thread.
85  */
86 - (FlutterEngine*)spawnWithEntrypoint:(nullable NSString*)entrypoint
87  libraryURI:(nullable NSString*)libraryURI
88  initialRoute:(nullable NSString*)initialRoute
89  entrypointArgs:(nullable NSArray<NSString*>*)entrypointArgs
90  NS_SWIFT_UI_ACTOR;
91 
92 /**
93  * Dispatches the given key event data to the framework through the engine.
94  * The callback is called once the response from the framework is received.
95  */
96 - (void)sendKeyEvent:(const FlutterKeyEvent&)event
97  callback:(nullable FlutterKeyEventCallback)callback
98  userData:(nullable void*)userData;
99 
100 @property(nonatomic, readonly) FlutterDartProject* project;
101 
102 /**
103  * Returns the engine handle. Used in FlutterEngineTest.
104  */
105 - (int64_t)engineIdentifier;
106 
107 /**
108  * Returns engine for the identifier. The identifier must be valid for an engine
109  * that is currently running, otherwise the behavior is undefined.
110  *
111  * The identifier can be obtained in Dart code through
112  * `PlatformDispatcher.instance.engineId`.
113  *
114  * This function must be called on the main thread.
115  */
116 + (nullable FlutterEngine*)engineForIdentifier:(int64_t)identifier;
117 
118 - (void)addSceneLifeCycleDelegate:(NSObject<FlutterSceneLifeCycleDelegate>*)delegate;
119 
120 /*
121  * Performs AppDelegate callback provided through the `FlutterImplicitEngineDelegate` protocol to
122  * inform apps that the implicit `FlutterEngine` has initialized.
123  */
124 - (BOOL)performImplicitEngineCallback;
125 
126 /*
127  * Creates a `FlutterEngineApplicationRegistrar` that can be used to access application-level
128  * services, such as the engine's `FlutterBinaryMessenger` or `FlutterTextureRegistry`.
129  */
130 - (NSObject<FlutterApplicationRegistrar>*)registrarForApplication:(NSString*)key;
131 
132 - (void)sendDeepLinkToFramework:(NSURL*)url completionHandler:(void (^)(BOOL success))completion;
133 
134 - (void)onStatusBarTap;
135 
136 /**
137  * Sends display information for the screen that the view controller's view is on, if it differs
138  * from the display last sent to the framework.
139  *
140  * If the view isn't in a window, keeps the last display sent. If no display has been sent yet,
141  * sends `UIScreen.mainScreen` as a best-effort initial display.
142  */
143 - (void)updateDisplays;
144 @end
145 
147 
148 @end
149 
151 
152 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERENGINE_INTERNAL_H_
#define NS_ASSUME_NONNULL_BEGIN
Definition: FlutterMacros.h:19
#define NS_ASSUME_NONNULL_END
Definition: FlutterMacros.h:20
FlutterTextInputPlugin * textInputPlugin
FlutterRestorationPlugin * restorationPlugin