Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/google_sign_in/google_sign_in_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.3

* Fix `renderButton` being stuck on "Getting ready" on web due to incorrect `FutureBuilder` state check.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was fixed in 1.1.2, so this changelog isn't accurate.


## 1.1.2

* Reverts "Throws a more actionable error when init is called more than once."
Expand Down Expand Up @@ -253,3 +257,4 @@
## 0.8.0

* Flutter for web initial release

Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class GoogleSignInPlugin extends GoogleSignInPlatform {
key: Key(config.hashCode.toString()),
future: initialized,
builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
if (snapshot.hasData) {
if (snapshot.connectionState == ConnectionState.done) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this change correctly handles a completed Future<void>, it's best practice to also handle potential errors. If the _initialized future completes with an error, snapshot.hasError will be true, and the widget should display an error state instead of attempting to render the button. Consider handling the error case explicitly for better robustness.

For example:

builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
  if (snapshot.hasError) {
    // In case of error, show an empty box or an error message.
    // Consider logging the error as well.
    return const SizedBox.shrink();
  }
  if (snapshot.connectionState == ConnectionState.done) {
    return FlexHtmlElementView(
      viewType: 'gsi_login_button',
      onElementCreated: (Object element) {
        _gisSdkClient.renderButton(element, config);
      },
    );
  }
  return const Text('Getting ready');
},

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without restoring all the changes reverted in 1.1.2, this change isn't really doing anything.

return FlexHtmlElementView(
viewType: 'gsi_login_button',
onElementCreated: (Object element) {
Expand Down
2 changes: 1 addition & 1 deletion packages/google_sign_in/google_sign_in_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading