Skip to content

Commit

Permalink
fix: Fixed a bug when Initialize is done at the same time.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Feb 1, 2023
1 parent 28e4035 commit 511fee9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
19 changes: 13 additions & 6 deletions packages/katana_firebase/lib/firebase/firebase_core.dart
Expand Up @@ -34,7 +34,8 @@ class FirebaseCore {
/// Returns `true` if Firebase is initialized.
///
/// Firebaseが初期化されている場合`true`を返します。
static bool get initialized => _app != null;
static bool get initialized => _initialized;
static bool _initialized = false;

/// Returns the Firebase region.
///
Expand Down Expand Up @@ -80,16 +81,22 @@ class FirebaseCore {
String region = "asia-northeast1",
FirebaseOptions? options,
}) async {
if (_app != null) {
if (initialized) {
return;
}
if (kIsWeb) {
assert(options != null, "For the Web, Options is always required.");
}
FirebaseCore.region = region;
_app = await Firebase.initializeApp(options: options);
if (!kIsWeb) {
FirebaseFirestore.instance.settings = const Settings();
_initialized = true;
try {
FirebaseCore.region = region;
_app = await Firebase.initializeApp(options: options);
if (!kIsWeb) {
FirebaseFirestore.instance.settings = const Settings();
}
} catch (e) {
_initialized = false;
rethrow;
}
}

Expand Down
12 changes: 6 additions & 6 deletions packages/katana_firebase/pubspec.lock
Expand Up @@ -276,10 +276,10 @@ packages:
dependency: "direct main"
description:
name: katana
sha256: fc59c8fd5c5eaeff569bff1bf37933ca9b2e69739c85dd3b6abffa63567a7cd4
sha256: "9a3ec047c35ec88e027139e88ce45202b022dd2111b38848c85159101b0028ce"
url: "https://pub.dev"
source: hosted
version: "1.0.3"
version: "1.0.5"
lints:
dependency: transitive
description:
Expand All @@ -292,10 +292,10 @@ packages:
dependency: transitive
description:
name: logging
sha256: c0bbfe94d46aedf9b8b3e695cf3bd48c8e14b35e3b2c639e0aa7755d589ba946
sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.1.1"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -457,10 +457,10 @@ packages:
dependency: transitive
description:
name: sprintf
sha256: ec76d38910b6f1c854ce1353c62d37e7ef82b53dc5ab048c25400d35970776d1
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
source: hosted
version: "6.0.2"
version: "7.0.0"
stack_trace:
dependency: transitive
description:
Expand Down

0 comments on commit 511fee9

Please sign in to comment.