Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions shell/platform/darwin/ios/framework/Headers/FlutterEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

@class FlutterViewController;

NS_ASSUME_NONNULL_BEGIN

/**
* The FlutterEngine class coordinates a single instance of execution for a
* `FlutterDartProject`. It may have zero or one `FlutterViewController` at a
Expand Down Expand Up @@ -56,9 +58,9 @@ FLUTTER_EXPORT
* @param labelPrefix The label prefix used to identify threads for this instance. Should
* be unique across FlutterEngine instances, and is used in instrumentation to label
* the threads used by this FlutterEngine.
* @param projectOrNil The `FlutterDartProject` to run.
* @param project The `FlutterDartProject` to run.
*/
- (instancetype)initWithName:(NSString*)labelPrefix project:(FlutterDartProject*)projectOrNil;
- (instancetype)initWithName:(NSString*)labelPrefix project:(nullable FlutterDartProject*)project;

/**
* Initialize this FlutterEngine with a `FlutterDartProject`.
Expand All @@ -73,12 +75,12 @@ FLUTTER_EXPORT
* @param labelPrefix The label prefix used to identify threads for this instance. Should
* be unique across FlutterEngine instances, and is used in instrumentation to label
* the threads used by this FlutterEngine.
* @param projectOrNil The `FlutterDartProject` to run.
* @param project The `FlutterDartProject` to run.
* @param allowHeadlessExecution Whether or not to allow this instance to continue
* running after passing a nil `FlutterViewController` to `-setViewController:`.
*/
- (instancetype)initWithName:(NSString*)labelPrefix
project:(FlutterDartProject*)projectOrNil
project:(nullable FlutterDartProject*)project
allowHeadlessExecution:(BOOL)allowHeadlessExecution NS_DESIGNATED_INITIALIZER;

/**
Expand All @@ -103,7 +105,7 @@ FLUTTER_EXPORT
* tree-shaken by the Dart compiler.
* @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
*/
- (BOOL)runWithEntrypoint:(NSString*)entrypoint;
- (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint;

/**
* Runs a Dart program on an Isolate using the specified entrypoint and Dart library,
Expand All @@ -120,7 +122,7 @@ FLUTTER_EXPORT
* this will default to the same library as the `main()` function in the Dart program.
* @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
*/
- (BOOL)runWithEntrypoint:(NSString*)entrypoint libraryURI:(NSString*)uri;
- (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint libraryURI:(nullable NSString*)uri;

/**
* Destroy running context for an engine.
Expand Down Expand Up @@ -177,11 +179,15 @@ FLUTTER_EXPORT
/**
* The `FlutterMethodChannel` used for localization related platform messages, such as
* setting the locale.
*
* Can be nil after `destroyContext` is called.
*/
@property(nonatomic, readonly) FlutterMethodChannel* localizationChannel;
@property(nonatomic, readonly, nullable) FlutterMethodChannel* localizationChannel;
/**
* The `FlutterMethodChannel` used for navigation related platform messages.
*
* Can be nil after `destroyContext` is called.
*
* @see [Navigation
* Channel](https://docs.flutter.io/flutter/services/SystemChannels/navigation-constant.html)
* @see [Navigator Widget](https://docs.flutter.io/flutter/widgets/Navigator-class.html)
Expand All @@ -191,13 +197,17 @@ FLUTTER_EXPORT
/**
* The `FlutterMethodChannel` used for core platform messages, such as
* information about the screen orientation.
*
* Can be nil after `destroyContext` is called.
*/
@property(nonatomic, readonly) FlutterMethodChannel* platformChannel;

/**
* The `FlutterMethodChannel` used to communicate text input events to the
* Dart Isolate.
*
* Can be nil after `destroyContext` is called.
*
* @see [Text Input
* Channel](https://docs.flutter.io/flutter/services/SystemChannels/textInput-constant.html)
*/
Expand All @@ -207,6 +217,8 @@ FLUTTER_EXPORT
* The `FlutterBasicMessageChannel` used to communicate app lifecycle events
* to the Dart Isolate.
*
* Can be nil after `destroyContext` is called.
*
* @see [Lifecycle
* Channel](https://docs.flutter.io/flutter/services/SystemChannels/lifecycle-constant.html)
*/
Expand All @@ -216,6 +228,8 @@ FLUTTER_EXPORT
* The `FlutterBasicMessageChannel` used for communicating system events, such as
* memory pressure events.
*
* Can be nil after `destroyContext` is called.
*
* @see [System
* Channel](https://docs.flutter.io/flutter/services/SystemChannels/system-constant.html)
*/
Expand All @@ -224,6 +238,8 @@ FLUTTER_EXPORT
/**
* The `FlutterBasicMessageChannel` used for communicating user settings such as
* clock format and text scale.
*
* Can be nil after `destroyContext` is called.
*/
@property(nonatomic, readonly) FlutterBasicMessageChannel* settingsChannel;

Expand All @@ -234,7 +250,7 @@ FLUTTER_EXPORT
* observatory service is ready. In release mode or before the observatory has
* started, it returns `nil`.
*/
@property(nonatomic, readonly) NSURL* observatoryUrl;
@property(nonatomic, readonly, nullable) NSURL* observatoryUrl;

/**
* The `FlutterBinaryMessenger` associated with this FlutterEngine (used for communicating with
Expand All @@ -247,8 +263,10 @@ FLUTTER_EXPORT
*
* This property will be nil if the engine is not running.
*/
@property(nonatomic, readonly, copy) NSString* isolateId;
@property(nonatomic, readonly, copy, nullable) NSString* isolateId;

@end

NS_ASSUME_NONNULL_END

#endif // FLUTTER_FLUTTERENGINE_H_
10 changes: 5 additions & 5 deletions shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ @implementation FlutterEngine {
FlutterBinaryMessengerRelay* _binaryMessenger;
}

- (instancetype)initWithName:(NSString*)labelPrefix project:(FlutterDartProject*)projectOrNil {
return [self initWithName:labelPrefix project:projectOrNil allowHeadlessExecution:YES];
- (instancetype)initWithName:(NSString*)labelPrefix project:(FlutterDartProject*)project {
return [self initWithName:labelPrefix project:project allowHeadlessExecution:YES];
}

- (instancetype)initWithName:(NSString*)labelPrefix
project:(FlutterDartProject*)projectOrNil
project:(FlutterDartProject*)project
allowHeadlessExecution:(BOOL)allowHeadlessExecution {
self = [super init];
NSAssert(self, @"Super init cannot be nil");
Expand All @@ -85,10 +85,10 @@ - (instancetype)initWithName:(NSString*)labelPrefix

_weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterEngine>>(self);

if (projectOrNil == nil)
if (project == nil)
_dartProject.reset([[FlutterDartProject alloc] init]);
else
_dartProject.reset([projectOrNil retain]);
_dartProject.reset([project retain]);

_pluginPublications = [NSMutableDictionary new];
_platformViewsController.reset(new flutter::FlutterPlatformViewsController());
Expand Down