diff --git a/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m b/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m index 2001cca02c7b..e5230b2c7ce4 100644 --- a/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m +++ b/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m @@ -68,7 +68,7 @@ @interface FLTFirebaseStoragePlugin () @implementation FLTFirebaseStoragePlugin { NSMutableDictionary *> *_tasks; dispatch_queue_t _callbackQueue; - bool hasEmulatorBooted; + NSMutableDictionary *_emulatorBooted; NSObject *_binaryMessenger; NSMutableDictionary *_eventChannels; NSMutableDictionary *> *_streamHandlers; @@ -97,7 +97,7 @@ - (instancetype)init:(NSObject *)messenger { dictionary]; _callbackQueue = dispatch_queue_create("io.flutter.plugins.firebase.storage", DISPATCH_QUEUE_SERIAL); - hasEmulatorBooted = false; + _emulatorBooted = [[NSMutableDictionary alloc] init]; _binaryMessenger = messenger; _eventChannels = [NSMutableDictionary dictionary]; _streamHandlers = [NSMutableDictionary dictionary]; @@ -242,9 +242,11 @@ - (void)useStorageEmulatorApp:(PigeonStorageFirebaseApp *)app port:(NSNumber *)port completion:(void (^)(FlutterError *_Nullable))completion { FIRStorage *storage = [self getFIRStorageFromAppNameFromPigeon:app]; - if (hasEmulatorBooted == false) { + NSNumber *emulatorKey = _emulatorBooted[app.bucket]; + + if (emulatorKey == nil) { [storage useEmulatorWithHost:host port:[port integerValue]]; - hasEmulatorBooted = true; + [_emulatorBooted setObject:@(YES) forKey:app.bucket]; } completion(nil); }