我想做什么
我正在尝试删除用户图像(通过设置 photoUrl = null(。 这是我的代码:
final UserUpdateInfo updatedInfo = UserUpdateInfo();
updatedInfo.photoUrl = null;
print(updatedInfo.photoUrl);
final user = await _auth.currentUser();
print('Before update: ${user.photoUrl}');
await user.updateProfile(updatedInfo);
await user.reload();
final newUser = await FirebaseAuth.instance.currentUser();
print('After update: ${newUser.photoUrl}');
预期输出:预期输出是从newUser.photoUrl
获得空。
实际输出
I/flutter (10813): null
I/flutter (10813): Before update: test20, https://firebasestorage.googleapis.com/v0/b/****/o/profileImages%2FIMG_20200129_133820.jpg?alt=media&token=6597dd66-e3b3-4b87-84b4-9000ceea54b4
I/flutter (10813): After update: test20, https://firebasestorage.googleapis.com/v0/b/****/o/profileImages%2FIMG_20200129_133820.jpg?alt=media&token=6597dd66-e3b3-4b87-84b4-9000ceea54b4
不知道实际问题是什么。如果我使用新网址更新 photoUrl,则相同的代码有效,但在将其设置为 null 时不起作用。
我遇到了同样的问题。
您必须设置:
{ photoURL: '' }
而不是null
.我认为这是一个错误。
J