From 23cd2e26662bb59fb37414cec92c38a52e1d68d9 Mon Sep 17 00:00:00 2001 From: Guillaume Bernos Date: Thu, 2 Feb 2023 14:45:37 +0100 Subject: [PATCH] hotfix to use when using an emulator with auth on web --- .../lib/firebase_auth_web.dart | 2 +- .../lib/src/interop/auth.dart | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart b/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart index 2200306a0044..9a3887a87b65 100644 --- a/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart +++ b/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart @@ -90,7 +90,7 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform { /// Called by PluginRegistry to register this plugin for Flutter Web static void registerWith(Registrar registrar) { FirebaseCoreWeb.registerService('auth', () async { - await FirebaseAuthWeb.instance.delegate.onWaitInitState(); + // await FirebaseAuthWeb.instance.delegate.onWaitInitState(); }); FirebaseAuthPlatform.instance = FirebaseAuthWeb.instance; PhoneMultiFactorGeneratorPlatform.instance = PhoneMultiFactorGeneratorWeb(); diff --git a/packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart b/packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart index 13dd764dd67a..85f22d90f73b 100644 --- a/packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart +++ b/packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart @@ -362,27 +362,27 @@ class Auth extends JsObjectWrapper { auth_interop.AuthSettings get settings => jsObject.settings; - User? _initUser; + // User? _initUser; - /// On web we need to wait for the first onAuthStateChanged event to fire - /// in order to be sure that the currentUser is set. - /// To preserve behavior on web and mobile we store the initial user - /// in `_initUser` and add it manually to the `_changeController`. - Future onWaitInitState() async { - final completer = Completer(); - final nextWrapper = allowInterop((auth_interop.UserJsImpl? user) { - _initUser = User.getInstance(user); - completer.complete(); - }); + // /// On web we need to wait for the first onAuthStateChanged event to fire + // /// in order to be sure that the currentUser is set. + // /// To preserve behavior on web and mobile we store the initial user + // /// in `_initUser` and add it manually to the `_changeController`. + // Future onWaitInitState() async { + // final completer = Completer(); + // final nextWrapper = allowInterop((auth_interop.UserJsImpl? user) { + // _initUser = User.getInstance(user); + // completer.complete(); + // }); - final errorWrapper = allowInterop((e) => _changeController!.addError(e)); + // final errorWrapper = allowInterop((e) => _changeController!.addError(e)); - final unsubscribe = jsObject.onAuthStateChanged(nextWrapper, errorWrapper); + // final unsubscribe = jsObject.onAuthStateChanged(nextWrapper, errorWrapper); - await completer.future; + // await completer.future; - unsubscribe(); - } + // unsubscribe(); + // } Func0? _onAuthUnsubscribe; // TODO(rrousselGit): fix memory leak – the controller isn't closed even in onCancel @@ -420,7 +420,7 @@ class Auth extends JsObjectWrapper { sync: true, ); - _changeController!.add(_initUser); + // _changeController!.add(_initUser); } return _changeController!.stream; }