Masterarbeit Richard Stern. Flutter App, sich mit einem Bluetooth-Gerät verbindet und Berührungen auf einem Sensor visualisiert.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FlutterEngine.h 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. #ifndef FLUTTER_FLUTTERENGINE_H_
  5. #define FLUTTER_FLUTTERENGINE_H_
  6. #import <Foundation/Foundation.h>
  7. #import <UIKit/UIKit.h>
  8. #include "FlutterBinaryMessenger.h"
  9. #include "FlutterDartProject.h"
  10. #include "FlutterMacros.h"
  11. #include "FlutterPlugin.h"
  12. #include "FlutterTexture.h"
  13. @class FlutterViewController;
  14. /**
  15. * The FlutterEngine class coordinates a single instance of execution for a
  16. * `FlutterDartProject`. It may have zero or one `FlutterViewController` at a
  17. * time, which can be specified via `-setViewController:`.
  18. * `FlutterViewController`'s `initWithEngine` initializer will automatically call
  19. * `-setViewController:` for itself.
  20. *
  21. * A FlutterEngine can be created independently of a `FlutterViewController` for
  22. * headless execution. It can also persist across the lifespan of multiple
  23. * `FlutterViewController` instances to maintain state and/or asynchronous tasks
  24. * (such as downloading a large file).
  25. *
  26. * Alternatively, you can simply create a new `FlutterViewController` with only a
  27. * `FlutterDartProject`. That `FlutterViewController` will internally manage its
  28. * own instance of a FlutterEngine, but will not guarantee survival of the engine
  29. * beyond the life of the ViewController.
  30. *
  31. * A newly initialized FlutterEngine will not actually run a Dart Isolate until
  32. * either `-runWithEntrypoint:` or `-runWithEntrypoint:libraryURI` is invoked.
  33. * One of these methods must be invoked before calling `-setViewController:`.
  34. */
  35. FLUTTER_EXPORT
  36. @interface FlutterEngine
  37. : NSObject <FlutterBinaryMessenger, FlutterTextureRegistry, FlutterPluginRegistry>
  38. /**
  39. * Initialize this FlutterEngine with a `FlutterDartProject`.
  40. *
  41. * If the FlutterDartProject is not specified, the FlutterEngine will attempt to locate
  42. * the project in a default location (the flutter_assets folder in the iOS application
  43. * bundle).
  44. *
  45. * A newly initialized engine will not run the `FlutterDartProject` until either
  46. * `-runWithEntrypoint:` or `-runWithEntrypoint:libraryURI:` is called.
  47. *
  48. * FlutterEngine created with this method will have allowHeadlessExecution set to `YES`.
  49. * This means that the engine will continue to run regardless of whether a `FlutterViewController`
  50. * is attached to it or not, until `-destroyContext:` is called or the process finishes.
  51. *
  52. * @param labelPrefix The label prefix used to identify threads for this instance. Should
  53. * be unique across FlutterEngine instances, and is used in instrumentation to label
  54. * the threads used by this FlutterEngine.
  55. * @param projectOrNil The `FlutterDartProject` to run.
  56. */
  57. - (instancetype)initWithName:(NSString*)labelPrefix project:(FlutterDartProject*)projectOrNil;
  58. /**
  59. * Initialize this FlutterEngine with a `FlutterDartProject`.
  60. *
  61. * If the FlutterDartProject is not specified, the FlutterEngine will attempt to locate
  62. * the project in a default location (the flutter_assets folder in the iOS application
  63. * bundle).
  64. *
  65. * A newly initialized engine will not run the `FlutterDartProject` until either
  66. * `-runWithEntrypoint:` or `-runWithEntrypoint:libraryURI:` is called.
  67. *
  68. * @param labelPrefix The label prefix used to identify threads for this instance. Should
  69. * be unique across FlutterEngine instances, and is used in instrumentation to label
  70. * the threads used by this FlutterEngine.
  71. * @param projectOrNil The `FlutterDartProject` to run.
  72. * @param allowHeadlessExecution Whether or not to allow this instance to continue
  73. * running after passing a nil `FlutterViewController` to `-setViewController:`.
  74. */
  75. - (instancetype)initWithName:(NSString*)labelPrefix
  76. project:(FlutterDartProject*)projectOrNil
  77. allowHeadlessExecution:(BOOL)allowHeadlessExecution NS_DESIGNATED_INITIALIZER;
  78. /**
  79. * The default initializer is not available for this object.
  80. * Callers must use `-[FlutterEngine initWithName:project:]`.
  81. */
  82. - (instancetype)init NS_UNAVAILABLE;
  83. + (instancetype)new NS_UNAVAILABLE;
  84. /**
  85. * Runs a Dart program on an Isolate from the main Dart library (i.e. the library that
  86. * contains `main()`).
  87. *
  88. * The first call to this method will create a new Isolate. Subsequent calls will return
  89. * immediately.
  90. *
  91. * @param entrypoint The name of a top-level function from the same Dart
  92. * library that contains the app's main() function. If this is nil, it will
  93. * default to `main()`. If it is not the app's main() function, that function
  94. * must be decorated with `@pragma(vm:entry-point)` to ensure the method is not
  95. * tree-shaken by the Dart compiler.
  96. * @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
  97. */
  98. - (BOOL)runWithEntrypoint:(NSString*)entrypoint;
  99. /**
  100. * Runs a Dart program on an Isolate using the specified entrypoint and Dart library,
  101. * which may not be the same as the library containing the Dart program's `main()` function.
  102. *
  103. * The first call to this method will create a new Isolate. Subsequent calls will return
  104. * immediately.
  105. *
  106. * @param entrypoint The name of a top-level function from a Dart library. If nil, this will
  107. * default to `main()`. If it is not the app's main() function, that function
  108. * must be decorated with `@pragma(vm:entry-point)` to ensure the method is not
  109. * tree-shaken by the Dart compiler.
  110. * @param uri The URI of the Dart library which contains the entrypoint method. IF nil,
  111. * this will default to the same library as the `main()` function in the Dart program.
  112. * @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
  113. */
  114. - (BOOL)runWithEntrypoint:(NSString*)entrypoint libraryURI:(NSString*)uri;
  115. /**
  116. * Destroy running context for an engine.
  117. *
  118. * This method can be used to force the FlutterEngine object to release all resources.
  119. * After sending this message, the object will be in an unusable state until it is deallocated.
  120. * Accessing properties or sending messages to it will result in undefined behavior or runtime
  121. * errors.
  122. */
  123. - (void)destroyContext;
  124. /**
  125. * Ensures that Flutter will generate a semantics tree.
  126. *
  127. * This is enabled by default if certain accessibility services are turned on by
  128. * the user, or when using a Simulator. This method allows a user to turn
  129. * semantics on when they would not ordinarily be generated and the performance
  130. * overhead is not a concern, e.g. for UI testing. Note that semantics should
  131. * never be programmatically turned off, as it would potentially disable
  132. * accessibility services an end user has requested.
  133. *
  134. * This method must only be called after launching the engine via
  135. * `-runWithEntrypoint:` or `-runWithEntryPoint:libraryURI`.
  136. *
  137. * Although this method returns synchronously, it does not guarantee that a
  138. * semantics tree is actually available when the method returns. It
  139. * synchronously ensures that the next frame the Flutter framework creates will
  140. * have a semantics tree.
  141. *
  142. * You can subscribe to semantics updates via `NSNotificationCenter` by adding
  143. * an observer for the name `FlutterSemanticsUpdateNotification`. The `object`
  144. * parameter will be the `FlutterViewController` associated with the semantics
  145. * update. This will asynchronously fire after a semantics tree has actually
  146. * built (which may be some time after the frame has been rendered).
  147. */
  148. - (void)ensureSemanticsEnabled;
  149. /**
  150. * Sets the `FlutterViewController` for this instance. The FlutterEngine must be
  151. * running (e.g. a successful call to `-runWithEntrypoint:` or `-runWithEntrypoint:libraryURI`)
  152. * before calling this method. Callers may pass nil to remove the viewController
  153. * and have the engine run headless in the current process.
  154. *
  155. * A FlutterEngine can only have one `FlutterViewController` at a time. If there is
  156. * already a `FlutterViewController` associated with this instance, this method will replace
  157. * the engine's current viewController with the newly specified one.
  158. *
  159. * Setting the viewController will signal the engine to start animations and drawing, and unsetting
  160. * it will signal the engine to stop animations and drawing. However, neither will impact the state
  161. * of the Dart program's execution.
  162. */
  163. @property(nonatomic, weak) FlutterViewController* viewController;
  164. /**
  165. * The `FlutterMethodChannel` used for localization related platform messages, such as
  166. * setting the locale.
  167. */
  168. @property(nonatomic, readonly) FlutterMethodChannel* localizationChannel;
  169. /**
  170. * The `FlutterMethodChannel` used for navigation related platform messages.
  171. *
  172. * @see [Navigation
  173. * Channel](https://docs.flutter.io/flutter/services/SystemChannels/navigation-constant.html)
  174. * @see [Navigator Widget](https://docs.flutter.io/flutter/widgets/Navigator-class.html)
  175. */
  176. @property(nonatomic, readonly) FlutterMethodChannel* navigationChannel;
  177. /**
  178. * The `FlutterMethodChannel` used for core platform messages, such as
  179. * information about the screen orientation.
  180. */
  181. @property(nonatomic, readonly) FlutterMethodChannel* platformChannel;
  182. /**
  183. * The `FlutterMethodChannel` used to communicate text input events to the
  184. * Dart Isolate.
  185. *
  186. * @see [Text Input
  187. * Channel](https://docs.flutter.io/flutter/services/SystemChannels/textInput-constant.html)
  188. */
  189. @property(nonatomic, readonly) FlutterMethodChannel* textInputChannel;
  190. /**
  191. * The `FlutterBasicMessageChannel` used to communicate app lifecycle events
  192. * to the Dart Isolate.
  193. *
  194. * @see [Lifecycle
  195. * Channel](https://docs.flutter.io/flutter/services/SystemChannels/lifecycle-constant.html)
  196. */
  197. @property(nonatomic, readonly) FlutterBasicMessageChannel* lifecycleChannel;
  198. /**
  199. * The `FlutterBasicMessageChannel` used for communicating system events, such as
  200. * memory pressure events.
  201. *
  202. * @see [System
  203. * Channel](https://docs.flutter.io/flutter/services/SystemChannels/system-constant.html)
  204. */
  205. @property(nonatomic, readonly) FlutterBasicMessageChannel* systemChannel;
  206. /**
  207. * The `FlutterBasicMessageChannel` used for communicating user settings such as
  208. * clock format and text scale.
  209. */
  210. @property(nonatomic, readonly) FlutterBasicMessageChannel* settingsChannel;
  211. /**
  212. * The `NSURL` of the observatory for the service isolate.
  213. *
  214. * This is only set in debug and profile runtime modes, and only after the
  215. * observatory service is ready. In release mode or before the observatory has
  216. * started, it returns `nil`.
  217. */
  218. @property(nonatomic, readonly) NSURL* observatoryUrl;
  219. @end
  220. #endif // FLUTTER_FLUTTERENGINE_H_