Refactor: FlutterDartProject (flutter/engine#13006)

- Removed unused instance variable
- Explicitly listed nullability
This commit is contained in:
gaaclarke
2019-10-09 07:21:44 -07:00
committed by GitHub
parent fd86b3b717
commit d4a3cc6b67
3 changed files with 20 additions and 14 deletions

View File

@@ -9,6 +9,8 @@
#include "FlutterMacros.h"
NS_ASSUME_NONNULL_BEGIN
/**
* A set of Flutter and Dart assets used by a `FlutterEngine` to initialize execution.
*/
@@ -18,7 +20,7 @@ FLUTTER_EXPORT
/**
* Initializes a Flutter Dart project from a bundle.
*/
- (instancetype)initWithPrecompiledDartBundle:(NSBundle*)bundle NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithPrecompiledDartBundle:(nullable NSBundle*)bundle NS_DESIGNATED_INITIALIZER;
/**
* Unavailable - use `init` instead.
@@ -44,7 +46,7 @@ FLUTTER_EXPORT
* @param bundle The `NSBundle` to use for looking up the asset.
* @return the file name to be used for lookup in the main bundle.
*/
+ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(NSBundle*)bundle;
+ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle;
/**
* Returns the file name for the given asset which originates from the specified package.
@@ -67,7 +69,7 @@ FLUTTER_EXPORT
*/
+ (NSString*)lookupKeyForAsset:(NSString*)asset
fromPackage:(NSString*)package
fromBundle:(NSBundle*)bundle;
fromBundle:(nullable NSBundle*)bundle;
/**
* Returns the default identifier for the bundle where we expect to find the Flutter Dart
@@ -77,4 +79,6 @@ FLUTTER_EXPORT
@end
NS_ASSUME_NONNULL_END
#endif // FLUTTER_FLUTTERDARTPROJECT_H_

View File

@@ -146,7 +146,6 @@ static flutter::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) {
}
@implementation FlutterDartProject {
fml::scoped_nsobject<NSBundle> _precompiledDartBundle;
flutter::Settings _settings;
}
@@ -158,11 +157,10 @@ static flutter::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) {
#pragma mark - Designated initializers
- (instancetype)initWithPrecompiledDartBundle:(NSBundle*)bundle {
- (instancetype)initWithPrecompiledDartBundle:(nullable NSBundle*)bundle {
self = [super init];
if (self) {
_precompiledDartBundle.reset([bundle retain]);
_settings = DefaultSettingsForProcess(bundle);
}
@@ -179,12 +177,12 @@ static flutter::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) {
return [self runConfigurationForEntrypoint:nil];
}
- (flutter::RunConfiguration)runConfigurationForEntrypoint:(NSString*)entrypointOrNil {
- (flutter::RunConfiguration)runConfigurationForEntrypoint:(nullable NSString*)entrypointOrNil {
return [self runConfigurationForEntrypoint:entrypointOrNil libraryOrNil:nil];
}
- (flutter::RunConfiguration)runConfigurationForEntrypoint:(NSString*)entrypointOrNil
libraryOrNil:(NSString*)dartLibraryOrNil {
- (flutter::RunConfiguration)runConfigurationForEntrypoint:(nullable NSString*)entrypointOrNil
libraryOrNil:(nullable NSString*)dartLibraryOrNil {
auto config = flutter::RunConfiguration::InferFromSettings(_settings);
if (dartLibraryOrNil && entrypointOrNil) {
config.SetEntrypointAndLibrary(std::string([entrypointOrNil UTF8String]),
@@ -216,7 +214,7 @@ static flutter::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) {
return [self lookupKeyForAsset:asset fromBundle:nil];
}
+ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(NSBundle*)bundle {
+ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle {
NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:bundle];
return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset];
}
@@ -227,7 +225,7 @@ static flutter::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) {
+ (NSString*)lookupKeyForAsset:(NSString*)asset
fromPackage:(NSString*)package
fromBundle:(NSBundle*)bundle {
fromBundle:(nullable NSBundle*)bundle {
return [self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset]
fromBundle:bundle];
}

View File

@@ -9,17 +9,21 @@
#include "flutter/shell/common/engine.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h"
NS_ASSUME_NONNULL_BEGIN
@interface FlutterDartProject ()
- (const flutter::Settings&)settings;
- (flutter::RunConfiguration)runConfiguration;
- (flutter::RunConfiguration)runConfigurationForEntrypoint:(NSString*)entrypointOrNil;
- (flutter::RunConfiguration)runConfigurationForEntrypoint:(NSString*)entrypointOrNil
libraryOrNil:(NSString*)dartLibraryOrNil;
- (flutter::RunConfiguration)runConfigurationForEntrypoint:(nullable NSString*)entrypointOrNil;
- (flutter::RunConfiguration)runConfigurationForEntrypoint:(nullable NSString*)entrypointOrNil
libraryOrNil:(nullable NSString*)dartLibraryOrNil;
+ (NSString*)flutterAssetsName:(NSBundle*)bundle;
@end
NS_ASSUME_NONNULL_END
#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_