Skip to content

Comments

[google_sign_in_web]Fix renderButton stuck on "Getting ready" for Web (Future<void> issue)#11081

Open
puneetkukreja98 wants to merge 3 commits intoflutter:mainfrom
puneetkukreja98:fix-render-button-void-future
Open

[google_sign_in_web]Fix renderButton stuck on "Getting ready" for Web (Future<void> issue)#11081
puneetkukreja98 wants to merge 3 commits intoflutter:mainfrom
puneetkukreja98:fix-render-button-void-future

Conversation

@puneetkukreja98
Copy link

@puneetkukreja98 puneetkukreja98 commented Feb 20, 2026

Previously, renderButton() used snapshot.hasData, but the Future completes with null on web.
This caused the button to never render, always showing "Getting ready".
Replaced with snapshot.connectionState == ConnectionState.done to fix.

Fixes: flutter/flutter#182633

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug in renderButton on the web, where the widget would remain in a "Getting ready" state. The change correctly updates the condition within the FutureBuilder to check snapshot.connectionState == ConnectionState.done instead of snapshot.hasData, which is the proper way to handle a Future<void>. I've included a suggestion to enhance robustness by also handling potential error states within the FutureBuilder.

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');
},

@puneetkukreja98
Copy link
Author

The current published version is 1.1.1.
This PR contains a bug fix only, this should be release as a patch version (1.1.2)

@stuartmorgan-g
Copy link
Collaborator

This PR contains a bug fix only, this should be release as a patch version (1.1.2)

This needs the changelog and version steps in the checklist as part of the PR for that to happen.

Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix @puneetkukreja98!

In addition to what @stuartmorgan-g said, would you mind also adding a test to protect us from the same issue in the future?

@puneetkukreja98
Copy link
Author

Thanks for the review @stuartmorgan-g & @mdebbar .
I’ve updated the version and CHANGELOG as requested.
I’ll add a test to prevent this regression and push an update shortly.

@puneetkukreja98 puneetkukreja98 force-pushed the fix-render-button-void-future branch from 07d7191 to af83e31 Compare February 22, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google_sign_in_web renderButton broken in v 1.1.1

3 participants