Skip to content

Commit 86ae6fe

Browse files
fix(core, web): do not throw if Firebase.apps called before initialising app (#13045)
1 parent 8ef7421 commit 86ae6fe

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/firebase_core/firebase_core_web/lib/src/firebase_core_web.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,16 @@ class FirebaseCoreWeb extends FirebasePlatform {
200200
/// Returns all created [FirebaseAppPlatform] instances.
201201
@override
202202
List<FirebaseAppPlatform> get apps {
203-
return guardNotInitialized(
204-
() => firebase.apps.map(_createFromJsApp).toList(growable: false),
205-
);
203+
try {
204+
return firebase.apps.map(_createFromJsApp).toList(growable: false);
205+
} catch (exception) {
206+
if (exception.toString().contains('of undefined')) {
207+
// Keeps behavior consistent with other platforms which can access list without initializing app.
208+
return [];
209+
} else {
210+
rethrow;
211+
}
212+
}
206213
}
207214

208215
/// Initializes a new [FirebaseAppPlatform] instance by [name] and [options] and returns

0 commit comments

Comments
 (0)