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 fdbfe4ac60ad..5c0b4abc0298 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.1.3 + +* Fix `renderButton` being stuck on "Getting ready" on web due to incorrect `FutureBuilder` state check. + ## 1.1.2 * Reverts "Throws a more actionable error when init is called more than once." @@ -253,3 +257,4 @@ ## 0.8.0 * Flutter for web initial release + diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/web_only_test.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/web_only_test.dart index dd86cd8cbe5c..5e0260e23d5e 100644 --- a/packages/google_sign_in/google_sign_in_web/example/integration_test/web_only_test.dart +++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/web_only_test.dart @@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/widgets.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart'; import 'package:google_sign_in_web/google_sign_in_web.dart' show GoogleSignInPlugin; +import 'package:google_sign_in_web/src/flexible_size_html_element_view.dart'; import 'package:google_sign_in_web/src/gis_client.dart'; import 'package:google_sign_in_web/web_only.dart' as web; import 'package:integration_test/integration_test.dart'; @@ -60,6 +61,22 @@ void main() { expect(button, isNotNull); }); + + testWidgets('renderButton shows loading then renders button', ( + WidgetTester tester, + ) async { + await tester.pumpWidget( + MaterialApp(home: Scaffold(body: web.renderButton())), + ); + + expect(find.text('Getting ready'), findsOneWidget); + + await tester.pumpAndSettle(const Duration(seconds: 3)); + + expect(find.text('Getting ready'), findsNothing); + + expect(find.byType(FlexHtmlElementView), findsOneWidget); + }); }); } 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 ab0b9b5ea5c0..acb35ead4a11 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 @@ -280,7 +280,7 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { key: Key(config.hashCode.toString()), future: initialized, builder: (BuildContext context, AsyncSnapshot snapshot) { - if (snapshot.hasData) { + if (snapshot.connectionState == ConnectionState.done) { return FlexHtmlElementView( viewType: 'gsi_login_button', onElementCreated: (Object element) { 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 30ff5db731af..c824fbdc9fa5 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.1.2 +version: 1.1.3 environment: sdk: ^3.9.0