signInSilently method

Future<GoogleSignInAccount?> signInSilently(
  1. {bool suppressErrors = true,
  2. bool reAuthenticate = false}
)

Attempts to sign in a previously authenticated user without interaction.

Returned Future resolves to an instance of GoogleSignInAccount for a successful sign in or null if there is no previously authenticated user. Use signIn method to trigger interactive sign in process.

Authentication is triggered if there is no currently signed in user (that is when currentUser == null), otherwise this method returns a Future which resolves to the same user instance.

Re-authentication can be triggered after signOut or disconnect. It can also be triggered by setting reAuthenticate to true if a new ID token is required.

When suppressErrors is set to false and an error occurred during sign in returned Future completes with PlatformException whose code can be one of kSignInRequiredError (when there is no authenticated user) , kNetworkError (when a network error occurred) or kSignInFailedError (when an unknown error occurred).

Implementation

Future<GoogleSignInAccount?> signInSilently({
  bool suppressErrors = true,
  bool reAuthenticate = false,
}) async {
  try {
    return await _addMethodCall(GoogleSignInPlatform.instance.signInSilently,
        canSkipCall: !reAuthenticate);
  } catch (_) {
    if (suppressErrors) {
      return null;
    } else {
      rethrow;
    }
  }
}