Skip to content

Commit

Permalink
await anonyUser.updateProfile before accessing user.displayName
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Wei committed Sep 27, 2020
1 parent 62ff87b commit 2a671d9
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/routes/firebase_login_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ class _FirebaseLoginExampleState extends State<FirebaseLoginExample> {
if (curUser != null && curUser.isAnonymous) {
return curUser;
}
_auth.signOut();
final anonyUser = (await _auth.signInAnonymously()).user;
anonyUser.updateProfile(
await anonyUser.updateProfile(
displayName: '${anonyUser.uid.substring(0, 5)}_Guest');
await anonyUser.reload();
// Have to re-call `currentUser()` to make `updateProfile` work.
Expand Down Expand Up @@ -153,7 +152,6 @@ class _FirebaseLoginExampleState extends State<FirebaseLoginExample> {
ListTile(title: Text('User id: ${user.uid}')),
ListTile(title: Text('Display name: ${user.displayName}')),
ListTile(title: Text('Anonymous: ${user.isAnonymous}')),
ListTile(title: Text('providerData: ${user.providerData}')),
ListTile(title: Text('Email: ${user.email}')),
ListTile(
title: Text('Profile photo: '),
Expand Down

0 comments on commit 2a671d9

Please sign in to comment.