Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Class Methods | Properties | List of all members
FlutterDartProject Class Reference

#include <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 20 of file FlutterDartProject.h.

Method Documentation

◆ allowsArbitraryLoads:

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

Definition at line 55 of file FlutterDartProject.mm.

394 :(NSDictionary*)appTransportSecurity {
395 return [[appTransportSecurity objectForKey:@"NSAllowsArbitraryLoads"] boolValue];
396}

◆ 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 55 of file FlutterDartProject.mm.

418 {
419 return @"io.flutter.flutter.app";
420}

◆ defaultPlatformData

- (const PlatformData) FlutterDartProject:
implementation

Definition at line 55 of file FlutterDartProject.mm.

310 {
311 flutter::PlatformData PlatformData;
312 PlatformData.lifecycle_state = std::string("AppLifecycleState.detached");
313 return PlatformData;
314}
std::string lifecycle_state

◆ domainNetworkPolicy:

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

Definition at line 55 of file FlutterDartProject.mm.

370 :(NSDictionary*)appTransportSecurity {
371 // https://developer.apple.com/documentation/bundleresources/information_property_list/nsapptransportsecurity/nsexceptiondomains
372 NSDictionary* exceptionDomains = [appTransportSecurity objectForKey:@"NSExceptionDomains"];
373 if (exceptionDomains == nil) {
374 return @"";
375 }
376 NSMutableArray* networkConfigArray = [[[NSMutableArray alloc] init] autorelease];
377 for (NSString* domain in exceptionDomains) {
378 NSDictionary* domainConfiguration = [exceptionDomains objectForKey:domain];
379 // Default value is false.
380 bool includesSubDomains =
381 [[domainConfiguration objectForKey:@"NSIncludesSubdomains"] boolValue];
382 bool allowsCleartextCommunication =
383 [[domainConfiguration objectForKey:@"NSExceptionAllowsInsecureHTTPLoads"] boolValue];
384 [networkConfigArray addObject:@[
385 domain, includesSubDomains ? @YES : @NO, allowsCleartextCommunication ? @YES : @NO
386 ]];
387 }
388 NSData* jsonData = [NSJSONSerialization dataWithJSONObject:networkConfigArray
389 options:0
390 error:NULL];
391 return [[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding] autorelease];
392}

◆ 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 55 of file FlutterDartProject.mm.

363 :(NSBundle*)bundle {
364 if (bundle == nil) {
366 }
367 return FLTAssetPath(bundle);
368}
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 55 of file FlutterDartProject.mm.

282 {
283 return [self initWithPrecompiledDartBundle:nil];
284}

◆ 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 55 of file FlutterDartProject.mm.

288 :(nullable NSBundle*)bundle {
289 self = [super init];
290
291 if (self) {
292 _settings = FLTDefaultSettingsForBundle(bundle);
293 }
294
295 return self;
296}
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 55 of file FlutterDartProject.mm.

298 :(const flutter::Settings&)settings {
299 self = [self initWithPrecompiledDartBundle:nil];
300
301 if (self) {
302 _settings = settings;
303 }
304
305 return self;
306}
const flutter::Settings & settings()

◆ isImpellerEnabled

- (BOOL) isImpellerEnabled
implementation

Definition at line 55 of file FlutterDartProject.mm.

426 {
427 return _settings.enable_impeller;
428}

◆ isWideGamutEnabled

- (BOOL) isWideGamutEnabled
implementation

Definition at line 55 of file FlutterDartProject.mm.

422 {
423 return _settings.enable_wide_gamut;
424}

◆ 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 55 of file FlutterDartProject.mm.

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

◆ 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 55 of file FlutterDartProject.mm.

402 :(NSString*)asset fromBundle:(nullable NSBundle*)bundle {
403 NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:bundle];
404 return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset];
405}

◆ 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 55 of file FlutterDartProject.mm.

407 :(NSString*)asset fromPackage:(NSString*)package {
408 return [self lookupKeyForAsset:asset fromPackage:package fromBundle:nil];
409}

◆ 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 55 of file FlutterDartProject.mm.

411 :(NSString*)asset
412 fromPackage:(NSString*)package
413 fromBundle:(nullable NSBundle*)bundle {
414 return [self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset]
415 fromBundle:bundle];
416}

◆ runConfiguration

- (RunConfiguration) FlutterDartProject:
implementation

Definition at line 55 of file FlutterDartProject.mm.

322 {
323 return [self runConfigurationForEntrypoint:nil];
324}

◆ runConfigurationForEntrypoint:

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

Definition at line 55 of file FlutterDartProject.mm.

326 :(nullable NSString*)entrypointOrNil {
327 return [self runConfigurationForEntrypoint:entrypointOrNil libraryOrNil:nil];
328}

◆ runConfigurationForEntrypoint:libraryOrNil:

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

Definition at line 55 of file FlutterDartProject.mm.

330 :(nullable NSString*)entrypointOrNil
331 libraryOrNil:(nullable NSString*)dartLibraryOrNil {
332 return [self runConfigurationForEntrypoint:entrypointOrNil
333 libraryOrNil:dartLibraryOrNil
334 entrypointArgs:nil];
335}

◆ runConfigurationForEntrypoint:libraryOrNil:entrypointArgs:

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

Definition at line 55 of file FlutterDartProject.mm.

337 :(nullable NSString*)entrypointOrNil
338 libraryOrNil:(nullable NSString*)dartLibraryOrNil
339 entrypointArgs:
340 (nullable NSArray<NSString*>*)entrypointArgs {
341 auto config = flutter::RunConfiguration::InferFromSettings(_settings);
342 if (dartLibraryOrNil && entrypointOrNil) {
343 config.SetEntrypointAndLibrary(std::string([entrypointOrNil UTF8String]),
344 std::string([dartLibraryOrNil UTF8String]));
345
346 } else if (entrypointOrNil) {
347 config.SetEntrypoint(std::string([entrypointOrNil UTF8String]));
348 }
349
350 if (entrypointArgs.count) {
351 std::vector<std::string> cppEntrypointArgs;
352 for (NSString* arg in entrypointArgs) {
353 cppEntrypointArgs.push_back(std::string([arg UTF8String]));
354 }
355 config.SetEntrypointArgs(std::move(cppEntrypointArgs));
356 }
357
358 return config;
359}

◆ settings

- (const Settings &) FlutterDartProject:
implementation

Definition at line 55 of file FlutterDartProject.mm.

318 {
319 return _settings;
320}

Property Documentation

◆ rootIsolateCreateCallback

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

The callback invoked by the engine in root isolate scope.

Provided by category FlutterDartProject().

Definition at line 32 of file FlutterDartProject_Internal.h.


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