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..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,3 +1,7 @@ +## 1.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/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', () { 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..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 @@ -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,13 @@ 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]); + return Future.wait(>[_jsSdkLoadedFuture]); } /// Stores the client ID if it was set in a meta-tag of the page. @@ -132,8 +116,6 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { assert(params.serverClientId == null, 'serverClientId is not supported on Web.'); - _initCalled = Completer(); - await _jsSdkLoadedFuture; _gisSdkClient ??= GisSdkClient( @@ -143,8 +125,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..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 +version: 1.0.1 environment: sdk: ^3.6.0