Commit 030f1738 authored by 余玠's avatar 余玠

get rid of the singleton function of FLBFlutterApplication

parent 6b9c1239
......@@ -111,26 +111,16 @@
return _instance;
}
- (id<FLBFlutterApplicationInterface>)application
{
return _application;
}
- (id<FLBAbstractFactory>)factory
{
return _factory;
}
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
onStart:(void (^)(FlutterEngine *engine))callback;
{
static dispatch_once_t onceToken;
__weak __typeof__(self) weakSelf = self;
dispatch_once(&onceToken, ^{
self->_factory = FLBFactory.new;
self->_application = [self->_factory createApplication:platform];
[self->_application startFlutterWithPlatform:platform
__strong __typeof__(weakSelf) self = weakSelf;
self.factory = FLBFactory.new;
self.application = [self->_factory createApplication:platform];
[self.application startFlutterWithPlatform:platform
onStart:callback];
});
}
......
......@@ -26,14 +26,11 @@
#import "FLBFlutterApplicationInterface.h"
#import "FLBAbstractFactory.h"
#import "FlutterBoostPlugin.h"
@interface FlutterBoostPlugin(){
id<FLBFlutterApplicationInterface> _application;
id<FLBAbstractFactory> _factory;
}
@interface FlutterBoostPlugin()
@property (nonatomic,strong) id<FLBFlutterApplicationInterface> application;
@property (nonatomic,strong) id<FLBAbstractFactory> factory;
@property (nonatomic,strong) FlutterMethodChannel *methodChannel;
@property (nonatomic,copy) NSString *fPageId;
@property (nonatomic,copy) NSString *fPagename;
@property (nonatomic,strong) NSDictionary *fParams;
- (id<FLBFlutterApplicationInterface>)application;
- (id<FLBAbstractFactory>)factory;
@end
......@@ -30,7 +30,7 @@
- (id<FLBFlutterApplicationInterface>)createApplication:(id<FLBPlatform>)platform
{
return [FLBFlutterApplication sharedApplication];
return [FLBFlutterApplication new];
}
- (id<FLBFlutterContainer>)createFlutterContainer
......
......@@ -30,6 +30,5 @@
NS_ASSUME_NONNULL_BEGIN
@interface FLBFlutterApplication : NSObject<FLBFlutterApplicationInterface>
+ (FLBFlutterApplication *)sharedApplication;
@end
NS_ASSUME_NONNULL_END
......@@ -39,16 +39,6 @@
@implementation FLBFlutterApplication
@synthesize platform;
+ (FLBFlutterApplication *)sharedApplication
{
static FLBFlutterApplication *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [self new];
});
return instance;
}
- (BOOL)isRunning
{
return _isRunning;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment