From 7a44a917c0113c1f8931bdff691091c09d87d830 Mon Sep 17 00:00:00 2001 From: Srivats Venkataraman <42980667+srivats22@users.noreply.github.com> Date: Tue, 29 Jul 2025 11:12:06 -0400 Subject: [PATCH 1/3] #167410: _initCalled completed twice --- .../google_sign_in_web/CHANGELOG.md | 4 ++++ .../lib/google_sign_in_web.dart | 21 +------------------ .../google_sign_in_web/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index 7e9920d0b8a..3cb667e3676 100644 --- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.0+1 + +* Fixes Bad state: Future already completed on the web + ## 1.0.0 * **BREAKING CHANGE**: Switches to implementing version 3.0 of the platform diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index 1285e60be97..2bad22cb7d8 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -67,8 +67,6 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { // A future that completes when the JS loader is done. late Future _jsSdkLoadedFuture; - // A future that completes when the `init` call is done. - Completer? _initCalled; // A StreamController to communicate status changes from the GisSdkClient. final StreamController _authenticationController; @@ -88,27 +86,14 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { return _gisSdkClient!; } - // This method throws if init or initWithParams hasn't been called at some - // point in the past. It is used by the [initialized] getter to ensure that - // users can't await on a Future that will never resolve. - void _assertIsInitCalled() { - if (_initCalled == null) { - throw StateError( - 'GoogleSignInPlugin::init() or GoogleSignInPlugin::initWithParams() ' - 'must be called before any other method in this plugin.', - ); - } - } - /// A future that resolves when the plugin is fully initialized. /// /// This ensures that the SDK has been loaded, and that the `init` method /// has finished running. @visibleForTesting Future get initialized { - _assertIsInitCalled(); return Future.wait( - >[_jsSdkLoadedFuture, _initCalled!.future]); + >[_jsSdkLoadedFuture]); } /// Stores the client ID if it was set in a meta-tag of the page. @@ -132,8 +117,6 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { assert(params.serverClientId == null, 'serverClientId is not supported on Web.'); - _initCalled = Completer(); - await _jsSdkLoadedFuture; _gisSdkClient ??= GisSdkClient( @@ -143,8 +126,6 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { authenticationController: _authenticationController, loggingEnabled: kDebugMode, ); - - _initCalled!.complete(); // Signal that `init` is fully done. } @override diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index faffd0143d1..401efc9edb5 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android, iOS and Web. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 1.0.0 +version: 1.0.0+1 environment: sdk: ^3.6.0 From d061d6a566ac81e7c8f9eb9d67001f327b5f9a27 Mon Sep 17 00:00:00 2001 From: Srivats Venkataraman <42980667+srivats22@users.noreply.github.com> Date: Tue, 29 Jul 2025 12:11:45 -0400 Subject: [PATCH 2/3] Fixing build issues --- packages/google_sign_in/google_sign_in_web/CHANGELOG.md | 2 +- .../google_sign_in_web/lib/google_sign_in_web.dart | 3 +-- packages/google_sign_in/google_sign_in_web/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index 3cb667e3676..1e203c9c31e 100644 --- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md @@ -1,6 +1,6 @@ ## 1.0.0+1 -* Fixes Bad state: Future already completed on the web +* Fixes Bad state: Future already completed on the web. ## 1.0.0 diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index 2bad22cb7d8..bd6b85bf48d 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -92,8 +92,7 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { /// has finished running. @visibleForTesting Future get initialized { - return Future.wait( - >[_jsSdkLoadedFuture]); + return Future.wait(>[_jsSdkLoadedFuture]); } /// Stores the client ID if it was set in a meta-tag of the page. diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index 401efc9edb5..ab2671447ae 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android, iOS and Web. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 1.0.0+1 +version: 1.0.1 environment: sdk: ^3.6.0 From 3ca9fc457bbe9ae6b02394d2801abcd40ba0e8cd Mon Sep 17 00:00:00 2001 From: Srivats Venkataraman <42980667+srivats22@users.noreply.github.com> Date: Thu, 31 Jul 2025 17:13:33 -0400 Subject: [PATCH 3/3] Fixing test issues --- .../google_sign_in_web/CHANGELOG.md | 2 +- .../google_sign_in_web_test.dart | 25 ------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index 1e203c9c31e..77ca9f9ffc0 100644 --- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.0.0+1 +## 1.0.1 * Fixes Bad state: Future already completed on the web. diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart index 911c73b3ebf..2b210c28932 100644 --- a/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart +++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/google_sign_in_web_test.dart @@ -91,31 +91,6 @@ void main() { ); }, throwsAssertionError); }); - - testWidgets('must be called for most of the API to work', (_) async { - expect(() async { - await plugin.attemptLightweightAuthentication( - const AttemptLightweightAuthenticationParameters()); - }, throwsStateError); - - expect(() async { - await plugin.clientAuthorizationTokensForScopes( - const ClientAuthorizationTokensForScopesParameters( - request: AuthorizationRequestDetails( - scopes: [], - userId: null, - email: null, - promptIfUnauthorized: false))); - }, throwsStateError); - - expect(() async { - await plugin.signOut(const SignOutParams()); - }, throwsStateError); - - expect(() async { - await plugin.disconnect(const DisconnectParams()); - }, throwsStateError); - }); }); group('support queries', () {