googleSignIn method

Future<bool> googleSignIn(
  1. GoogleSignInAccount creds,
  2. String accessToken
)

Implementation

Future<bool> googleSignIn(
  GoogleSignInAccount creds,
  String accessToken,
) async {
  try {
    final ResponseModel<AccessResponse> responseModel =
        await ResponseModel.fromApiResponse<AccessResponse>(
      () async => await AuthApiService().signInUser(
        AccessRequest(
          email: creds.email,
          username: creds.displayName,
          fullName: creds.displayName,
          socialPlatform: "google",
          clientId: creds.id,
          token: accessToken,
          deviceToken: notificationDeviceToken,
          deviceType: 'mobile',
          platform: Platform.isIOS ? "ios" : 'android',
        ),
        isSocial: true,
      ),
      (body) => AccessResponse.fromJson(body),
    );
    if (responseModel.status == ResponseStatus.success) {
      await TokenManager()
          .setToken(responseModel.response!.data!.accessToken!.token!);
      await UserManager().saveUser(responseModel.response!.data!.user!);
      return true;
    } else if (responseModel.status == ResponseStatus.responseError ||
        responseModel.status == ResponseStatus.nullResponse) {
      SnackbarManager().showAlertSnackbar(responseModel.error!);
    }
  } on Exception catch (e) {
    ExceptionHandler().handle(e);
  }
  return false;
}