14 @property(nonatomic, copy) NSString* name;
15 @property(nonatomic, strong) NSMutableArray<NSValue*>* engines;
17 @property(nonatomic, assign) NSUInteger enginesCreatedCount;
26 _engines = [[NSMutableArray<NSValue*> alloc] init];
32 - (
FlutterEngine*)makeEngineWithEntrypoint:(nullable NSString*)entrypoint
33 libraryURI:(nullable NSString*)libraryURI {
37 - (
FlutterEngine*)makeEngineWithEntrypoint:(nullable NSString*)entrypoint
38 libraryURI:(nullable NSString*)libraryURI
39 initialRoute:(nullable NSString*)initialRoute {
54 if (
self.engines.count <= 0) {
55 engine = [
self makeEngine];
68 [
self.engines addObject:[NSValue valueWithPointer:(__bridge void*)engine]];
70 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
71 [center addObserver:self
72 selector:@selector(onEngineWillBeDealloced:)
73 name:kFlutterEngineWillDealloc
80 NSString* engineName =
81 [NSString stringWithFormat:@"%@.%lu", self.name, ++self.enginesCreatedCount];
82 return [[
FlutterEngine alloc] initWithName:engineName project:self.project];
85 - (void)onEngineWillBeDealloced:(NSNotification*)notification {
87 [
self.engines removeObject:[NSValue valueWithPointer:(__bridge void*)notification.object]];