signInAnonymously method Null safety

Future<UserCredential> signInAnonymously()

Asynchronously creates and becomes an anonymous user.

If there is already an anonymous user signed in, that user will be returned instead. If there is any other existing user signed in, that user will be signed out.

Important: You must enable Anonymous accounts in the Auth section of the Firebase console before being able to use them.

A FirebaseAuthException maybe thrown with the following error code:

  • operation-not-allowed:
  • Thrown if anonymous accounts are not enabled. Enable anonymous accounts in the Firebase Console, under the Auth tab.

Implementation

Future<UserCredential> signInAnonymously() async {
  return UserCredential._(this, await _delegate.signInAnonymously());
}