Flutter Engine
The Flutter Engine
Instance Methods | Class Methods | Properties | List of all members
FlutterDartProject Class Reference

#import <FlutterDartProject.h>

Inheritance diagram for FlutterDartProject:

Instance Methods

(instancetype) - initWithPrecompiledDartBundle:
 
("Use -init instead.") - FLUTTER_UNAVAILABLE
 
(NSArray< NSString * > *dartEntrypointArguments) - API_UNAVAILABLE
 
(instancetype) - init [implementation]
 
(instancetype) - initWithSettings: [implementation]
 
(const flutter::PlatformData- defaultPlatformData [implementation]
 
(const flutter::Settings &) - settings [implementation]
 
(flutter::RunConfiguration- runConfiguration [implementation]
 
(flutter::RunConfiguration- runConfigurationForEntrypoint: [implementation]
 
(flutter::RunConfiguration- runConfigurationForEntrypoint:libraryOrNil: [implementation]
 
(flutter::RunConfiguration- runConfigurationForEntrypoint:libraryOrNil:entrypointArgs: [implementation]
 
(BOOL- isWideGamutEnabled [implementation]
 
(BOOL- isImpellerEnabled [implementation]
 
(instancetype) - initWithPrecompiledDartBundle: [implementation]
 
(instancetype) - initWithAssetsPath:ICUDataPath: [implementation]
 
(BOOL- enableImpeller [implementation]
 
(NSString *) - assetsPath [implementation]
 
(NSString *) - ICUDataPath [implementation]
 

Class Methods

(NSString *) + defaultBundleIdentifier
 
(NSString *) + lookupKeyForAsset:
 
(NSString *) + lookupKeyForAsset:fromBundle:
 
(NSString *) + lookupKeyForAsset:fromPackage:
 
(NSString *) + lookupKeyForAsset:fromPackage:fromBundle:
 
(NSString *) + flutterAssetsName: [implementation]
 
(NSString *) + domainNetworkPolicy: [implementation]
 
(bool) + allowsArbitraryLoads: [implementation]
 
(NSString *) + flutterAssetsNameWithBundle: [implementation]
 

Properties

void(* rootIsolateCreateCallback )(void *_Nullable) [implementation]
 

Detailed Description

A set of Flutter and Dart assets used by a FlutterEngine to initialize execution.

Definition at line 19 of file FlutterDartProject.h.

Method Documentation

◆ allowsArbitraryLoads:

+ (bool) allowsArbitraryLoads: (NSDictionary*)  appTransportSecurity
implementation

Definition at line 46 of file FlutterDartProject.mm.

384 :(NSDictionary*)appTransportSecurity {
385 return [appTransportSecurity[@"NSAllowsArbitraryLoads"] boolValue];
386}

◆ API_UNAVAILABLE

- (NSArray< NSString * > *dartEntrypointArguments) API_UNAVAILABLE (ios) 

An NSArray of NSStrings to be passed as command line arguments to the Dart entrypoint.

If this is not explicitly set, this will default to the contents of [NSProcessInfo arguments], without the binary name.

Set this to nil to pass no arguments to the Dart entrypoint.

◆ assetsPath

- (NSString *) assetsPath
implementation

The path to the Flutter assets directory.

Definition at line 27 of file FlutterDartProject.mm.

71 {
72 if (_assetsPath) {
73 return _assetsPath;
74 }
75
76 // If there's no App.framework, fall back to checking the main bundle for assets.
77 NSBundle* assetBundle = _dartBundle ?: [NSBundle mainBundle];
78 NSString* flutterAssetsName = [assetBundle objectForInfoDictionaryKey:@"FLTAssetsPath"];
79 if (flutterAssetsName == nil) {
80 flutterAssetsName = @"flutter_assets";
81 }
82 NSString* path = [assetBundle pathForResource:flutterAssetsName ofType:@""];
83 if (!path) {
84 NSLog(@"Failed to find path for \"%@\"", flutterAssetsName);
85 }
86 return path;
87}
NSString * _assetsPath
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57

◆ defaultBundleIdentifier

+ (NSString *) defaultBundleIdentifier

Returns the default identifier for the bundle where we expect to find the Flutter Dart application.

Definition at line 46 of file FlutterDartProject.mm.

408 {
409 return @"io.flutter.flutter.app";
410}

◆ defaultPlatformData

- (const PlatformData) FlutterDartProject:
implementation

Definition at line 46 of file FlutterDartProject.mm.

301 {
302 flutter::PlatformData PlatformData;
303 PlatformData.lifecycle_state = std::string("AppLifecycleState.detached");
304 return PlatformData;
305}
std::string lifecycle_state
Definition: platform_data.h:44

◆ domainNetworkPolicy:

+ (NSString *) domainNetworkPolicy: (NSDictionary*)  appTransportSecurity
implementation

Definition at line 46 of file FlutterDartProject.mm.

361 :(NSDictionary*)appTransportSecurity {
362 // https://developer.apple.com/documentation/bundleresources/information_property_list/nsapptransportsecurity/nsexceptiondomains
363 NSDictionary* exceptionDomains = appTransportSecurity[@"NSExceptionDomains"];
364 if (exceptionDomains == nil) {
365 return @"";
366 }
367 NSMutableArray* networkConfigArray = [[NSMutableArray alloc] init];
368 for (NSString* domain in exceptionDomains) {
369 NSDictionary* domainConfiguration = exceptionDomains[domain];
370 // Default value is false.
371 bool includesSubDomains = [domainConfiguration[@"NSIncludesSubdomains"] boolValue];
372 bool allowsCleartextCommunication =
373 [domainConfiguration[@"NSExceptionAllowsInsecureHTTPLoads"] boolValue];
374 [networkConfigArray addObject:@[
375 domain, includesSubDomains ? @YES : @NO, allowsCleartextCommunication ? @YES : @NO
376 ]];
377 }
378 NSData* jsonData = [NSJSONSerialization dataWithJSONObject:networkConfigArray
379 options:0
380 error:NULL];
381 return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
382}

◆ enableImpeller

- (BOOL) enableImpeller
implementation

Whether the Impeller rendering backend is enabled

Definition at line 27 of file FlutterDartProject.mm.

62 {
63 NSNumber* enableImpeller =
64 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTEnableImpeller"];
65 if (enableImpeller != nil) {
66 return enableImpeller.boolValue;
67 }
68 return NO;
69}

◆ FLUTTER_UNAVAILABLE

- ("Use -init instead.") FLUTTER_UNAVAILABLE

Unavailable - use init instead.

◆ flutterAssetsName:

+ (NSString *) flutterAssetsName: (NSBundle*)  bundle
implementation

Definition at line 46 of file FlutterDartProject.mm.

354 :(NSBundle*)bundle {
355 if (bundle == nil) {
357 }
358 return FLTAssetPath(bundle);
359}
NSBundle * FLTFrameworkBundleWithIdentifier(NSString *flutterFrameworkBundleID)
NSString * FLTAssetPath(NSBundle *bundle)
NSString * defaultBundleIdentifier()

◆ flutterAssetsNameWithBundle:

+ (NSString *) flutterAssetsNameWithBundle: (NSBundle*)  bundle
implementation

Definition at line 27 of file FlutterDartProject.mm.

102 :(NSBundle*)bundle {
103 if (bundle == nil) {
105 }
106 if (bundle == nil) {
107 bundle = [NSBundle mainBundle];
108 }
109 NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"];
110 if (flutterAssetsName == nil) {
111 flutterAssetsName = @"Contents/Frameworks/App.framework/Resources/flutter_assets";
112 }
113 return flutterAssetsName;
114}
static NSString *const kAppBundleIdentifier

◆ ICUDataPath

- (NSString *) ICUDataPath
implementation

The path to the ICU data file.

Definition at line 27 of file FlutterDartProject.mm.

89 {
90 if (_ICUDataPath) {
91 return _ICUDataPath;
92 }
93
94 NSString* path = [[NSBundle bundleForClass:[self class]] pathForResource:kICUBundlePath
95 ofType:nil];
96 if (!path) {
97 NSLog(@"Failed to find path for \"%@\"", kICUBundlePath);
98 }
99 return path;
100}
static NSString *const kICUBundlePath
NSString * _ICUDataPath

◆ init

- (instancetype) init
implementation

Definition at line 46 of file FlutterDartProject.mm.

273 {
274 return [self initWithPrecompiledDartBundle:nil];
275}

◆ initWithAssetsPath:ICUDataPath:

- (instancetype) initWithAssetsPath: (NSString*)  assets
ICUDataPath: (NSString*)  icuPath 
implementation

Definition at line 27 of file FlutterDartProject.mm.

54 :(NSString*)assets ICUDataPath:(NSString*)icuPath {
55 self = [super init];
56 NSAssert(self, @"Super init cannot be nil");
57 _assetsPath = assets;
58 _ICUDataPath = icuPath;
59 return self;
60}

◆ initWithPrecompiledDartBundle: [1/2]

- (instancetype) initWithPrecompiledDartBundle: (NSBundle*)  bundle
implementation

Definition at line 27 of file FlutterDartProject.mm.

34 :(NSBundle*)bundle {
35 self = [super init];
36 NSAssert(self, @"Super init cannot be nil");
37
39 if (_dartBundle == nil) {
40 // The bundle isn't loaded and can't be found by bundle ID. Find it by path.
41 _dartBundle = [NSBundle bundleWithURL:[NSBundle.mainBundle.privateFrameworksURL
42 URLByAppendingPathComponent:@"App.framework"]];
43 }
44 if (!_dartBundle.isLoaded) {
45 [_dartBundle load];
46 }
47 _dartEntrypointArguments = [[NSProcessInfo processInfo] arguments];
48 // Remove the first element as it's the binary name
49 _dartEntrypointArguments = [_dartEntrypointArguments
50 subarrayWithRange:NSMakeRange(1, _dartEntrypointArguments.count - 1)];
51 return self;
52}

◆ initWithPrecompiledDartBundle: [2/2]

- (instancetype) initWithPrecompiledDartBundle: (nullable NSBundle*)  NS_DESIGNATED_INITIALIZER

Initializes a Flutter Dart project from a bundle.

The bundle must either contain a flutter_assets resource directory, or set the Info.plist key FLTAssetsPath to override that name (if you are doing a custom build using a different name).

Parameters
bundleThe bundle containing the Flutter assets directory. If nil, the App framework created by Flutter will be used.

Definition at line 46 of file FlutterDartProject.mm.

279 :(nullable NSBundle*)bundle {
280 self = [super init];
281
282 if (self) {
283 _settings = FLTDefaultSettingsForBundle(bundle);
284 }
285
286 return self;
287}
flutter::Settings FLTDefaultSettingsForBundle(NSBundle *bundle, NSProcessInfo *processInfoOrNil)

◆ initWithSettings:

- (instancetype) initWithSettings: (const flutter::Settings &)  settings
implementation

This is currently used for only for tests to override settings.

Definition at line 46 of file FlutterDartProject.mm.

289 :(const flutter::Settings&)settings {
290 self = [self initWithPrecompiledDartBundle:nil];
291
292 if (self) {
293 _settings = settings;
294 }
295
296 return self;
297}
const flutter::Settings & settings()

◆ isImpellerEnabled

- (BOOL) isImpellerEnabled
implementation

Definition at line 46 of file FlutterDartProject.mm.

416 {
417 return _settings.enable_impeller;
418}

◆ isWideGamutEnabled

- (BOOL) isWideGamutEnabled
implementation

Definition at line 46 of file FlutterDartProject.mm.

412 {
413 return _settings.enable_wide_gamut;
414}

◆ lookupKeyForAsset:

+ (NSString *) lookupKeyForAsset: (NSString*)  asset

Returns the file name for the given asset. If the bundle with the identifier "io.flutter.flutter.app" exists, it will try use that bundle; otherwise, it will use the main bundle. To specify a different bundle, use +lookupKeyForAsset:fromBundle.

Parameters
assetThe name of the asset. The name can be hierarchical.
Returns
the file name to be used for lookup in the main bundle.

Definition at line 46 of file FlutterDartProject.mm.

388 :(NSString*)asset {
389 return [self lookupKeyForAsset:asset fromBundle:nil];
390}

◆ lookupKeyForAsset:fromBundle:

+ (NSString *) lookupKeyForAsset: (NSString*)  asset
fromBundle: (nullable NSBundle*)  bundle 

Returns the file name for the given asset. The returned file name can be used to access the asset in the supplied bundle.

Parameters
assetThe name of the asset. The name can be hierarchical.
bundleThe NSBundle to use for looking up the asset.
Returns
the file name to be used for lookup in the main bundle.

Definition at line 46 of file FlutterDartProject.mm.

392 :(NSString*)asset fromBundle:(nullable NSBundle*)bundle {
393 NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:bundle];
394 return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset];
395}
NSString * flutterAssetsName:(NSBundle *bundle)

◆ lookupKeyForAsset:fromPackage:

+ (NSString *) lookupKeyForAsset: (NSString*)  asset
fromPackage: (NSString*)  package 

Returns the file name for the given asset which originates from the specified package. The returned file name can be used to access the asset in the application's main bundle.

Parameters
assetThe name of the asset. The name can be hierarchical.
packageThe name of the package from which the asset originates.
Returns
the file name to be used for lookup in the main bundle.

Definition at line 46 of file FlutterDartProject.mm.

397 :(NSString*)asset fromPackage:(NSString*)package {
398 return [self lookupKeyForAsset:asset fromPackage:package fromBundle:nil];
399}

◆ lookupKeyForAsset:fromPackage:fromBundle:

+ (NSString *) lookupKeyForAsset: (NSString*)  asset
fromPackage: (NSString*)  package
fromBundle: (nullable NSBundle*)  bundle 

Returns the file name for the given asset which originates from the specified package. The returned file name can be used to access the asset in the specified bundle.

Parameters
assetThe name of the asset. The name can be hierarchical.
packageThe name of the package from which the asset originates.
bundleThe bundle to use when doing the lookup.
Returns
the file name to be used for lookup in the main bundle.

Definition at line 46 of file FlutterDartProject.mm.

401 :(NSString*)asset
402 fromPackage:(NSString*)package
403 fromBundle:(nullable NSBundle*)bundle {
404 return [self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset]
405 fromBundle:bundle];
406}

◆ runConfiguration

- (RunConfiguration) FlutterDartProject:
implementation

Definition at line 46 of file FlutterDartProject.mm.

313 {
314 return [self runConfigurationForEntrypoint:nil];
315}

◆ runConfigurationForEntrypoint:

- (RunConfiguration) FlutterDartProject: (nullable NSString*)  entrypointOrNil
implementation

Definition at line 46 of file FlutterDartProject.mm.

317 :(nullable NSString*)entrypointOrNil {
318 return [self runConfigurationForEntrypoint:entrypointOrNil libraryOrNil:nil];
319}

◆ runConfigurationForEntrypoint:libraryOrNil:

- (RunConfiguration) FlutterDartProject: (nullable NSString*)  entrypointOrNil
libraryOrNil: (nullable NSString*)  dartLibraryOrNil 
implementation

Definition at line 46 of file FlutterDartProject.mm.

321 :(nullable NSString*)entrypointOrNil
322 libraryOrNil:(nullable NSString*)dartLibraryOrNil {
323 return [self runConfigurationForEntrypoint:entrypointOrNil
324 libraryOrNil:dartLibraryOrNil
325 entrypointArgs:nil];
326}

◆ runConfigurationForEntrypoint:libraryOrNil:entrypointArgs:

- (RunConfiguration) FlutterDartProject: (nullable NSString*)  entrypointOrNil
libraryOrNil: (nullable NSString*)  dartLibraryOrNil
entrypointArgs: (nullable NSArray<NSString*>*)  entrypointArgs 
implementation

Definition at line 46 of file FlutterDartProject.mm.

328 :(nullable NSString*)entrypointOrNil
329 libraryOrNil:(nullable NSString*)dartLibraryOrNil
330 entrypointArgs:
331 (nullable NSArray<NSString*>*)entrypointArgs {
332 auto config = flutter::RunConfiguration::InferFromSettings(_settings);
333 if (dartLibraryOrNil && entrypointOrNil) {
334 config.SetEntrypointAndLibrary(std::string([entrypointOrNil UTF8String]),
335 std::string([dartLibraryOrNil UTF8String]));
336
337 } else if (entrypointOrNil) {
338 config.SetEntrypoint(std::string([entrypointOrNil UTF8String]));
339 }
340
341 if (entrypointArgs.count) {
342 std::vector<std::string> cppEntrypointArgs;
343 for (NSString* arg in entrypointArgs) {
344 cppEntrypointArgs.push_back(std::string([arg UTF8String]));
345 }
346 config.SetEntrypointArgs(std::move(cppEntrypointArgs));
347 }
348
349 return config;
350}
static RunConfiguration InferFromSettings(const Settings &settings, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup)
Attempts to infer a run configuration from the settings object. This tries to create a run configurat...

◆ settings

- (const Settings &) FlutterDartProject:
implementation

Definition at line 46 of file FlutterDartProject.mm.

309 {
310 return _settings;
311}

Property Documentation

◆ rootIsolateCreateCallback

- (void(* rootIsolateCreateCallback) (void *_Nullable))
readwritenonatomicassignimplementation

The callback invoked by the engine in root isolate scope.

Definition at line 32 of file FlutterDartProject_Internal.h.


The documentation for this class was generated from the following files: