initWithParams method

  1. @override
Future<void> initWithParams(
  1. SignInInitParameters params
)
override

Initializes the plugin with specified params. You must call this method before calling other methods.

See:

  • SignInInitParameters

Implementation

@override
Future<void> initWithParams(SignInInitParameters params) async {
  final String? appClientId = params.clientId ?? autoDetectedClientId;
  assert(
      appClientId != null,
      'ClientID not set. Either set it on a '
      '<meta name="google-signin-client_id" content="CLIENT_ID" /> tag,'
      ' or pass clientId when initializing GoogleSignIn');

  assert(params.serverClientId == null,
      'serverClientId is not supported on Web.');

  assert(
      !params.scopes.any((String scope) => scope.contains(' ')),
      "OAuth 2.0 Scopes for Google APIs can't contain spaces. "
      'Check https://developers.google.com/identity/protocols/googlescopes '
      'for a list of valid OAuth 2.0 scopes.');

  _initCalled = Completer<void>();

  await _jsSdkLoadedFuture;

  _gisSdkClient ??= GisSdkClient(
    clientId: appClientId!,
    hostedDomain: params.hostedDomain,
    initialScopes: List<String>.from(params.scopes),
    userDataController: _userDataController,
    loggingEnabled: kDebugMode,
  );

  _initCalled!.complete(); // Signal that `init` is fully done.
}