Flutter和Google Sing-in:无效的图像数据



我已经用FlutterFire实现了Google身份验证。我使用官方软件包在用户中唱歌。

但是,如果我导航到一个可以看到用户配置文件图片的页面,并尝试渲染GoogleUserCircleAvatarar,尽管该页面似乎工作得很好,但我在控制台中收到一个错误:


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

在屏幕上,加载图片需要几毫秒的时间。在加载之前,我可以看到用户名和电子邮件地址旁边的占位符图像(填充背景上用户首字母缩写的第一个字母((因此加载了currentUser(,它将转换为用户配置文件图片。当我使用推荐的Widget时,我很困惑应该如何防止错误发生。

代码:

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对象是使用官方API:创建的

currentUser = await GoogleSignIn().signIn();

和我的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"

这个问题应该在最新版本的google_sign_in插件上解决。关于该问题的修复的更多细节将在本次拉取请求中讨论。

最新更新