Flutter and Google Sing in: Invalid image data

Viewed 1543

I have implemented Google Authentication with FlutterFire. I use the official package to sing in users.

However, if I navigate to a page where the user profile picture is seen and try to render the GoogleUserCircleAvatarar, although the page seems to be working just fine, I get an error in the console:


════════ Exception caught by image resource service ════════════════════════════════════════════════
Exception: Invalid image data
════════════════════════════════════════════════════════════════════════════════════════════════════

On the screen, it takes a few milliseconds, to load up the picture. Before it's loaded, I can see the placeholder image (First letter of the users initials on a filled background) next to the user's name and email address (so the currentUser is loaded) which transitions to the user profile picture. As I am using the recommended Widget, I am confused how should I prevent the error from happening.

Code:

if (widget.userService.currentUser != null) {
      return Column(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          ListTile(
            leading: GoogleUserCircleAvatar(
              identity: widget.userService.currentUser,
            ),
            title: Text(widget.userService.currentUser.displayName ?? ''),
            subtitle: Text(widget.userService.currentUser.email ?? ''),
          ),
          const Text("Signed in successfully."),
          RaisedButton(
            child: const Text('SIGN OUT'),
            onPressed: _handleSignOut,
          ),
        ],
      );
    } else {
      ...

currentUser object is created with the official API:

      currentUser = await GoogleSignIn().signIn();

and my pubspec.yml:


dependencies:
  flutter:
    sdk: flutter
  cloud_firestore: ^0.14.0+1
  provider: ^4.3.2+2
  google_sign_in: "^4.5.1"
  firebase_core: "^0.5.0+1"
  firebase_auth: "^0.18.1+2"

1 Answers

This issue should've resolved on the latest version of the google_sign_in plugin. More details of the fix for the issue is discussed on this pull request.

Related