login method Null safety

Future<LoginResponse?> login(
  1. AuthInfo info,
  2. [ResponseCallback<LoginResponse>? callback]
)

This function takes an AuthInfo object and an optional ResponseCallback function, and returns a Future.

Args: info (AuthInfo): The AuthInfo object that contains the login information. callback (ResponseCallback): The callback function that will be called when the request is complete.

Implementation

Future<LoginResponse?> login(AuthInfo info, [ResponseCallback<LoginResponse>? callback]) async {
  final resp = await MotorFlutterPlatform.instance.login(LoginRequest(
    password: info.password,
    did: info.did,
    aesDscKey: info.aesDscKey,
    aesPskKey: info.aesPskKey,
  ));
  if (callback != null) {
    callback(resp);
  }
  if (resp != null) {
    address.value = info.address;
    didUrl.value = resp.whoIs.didDocument.id;
    didDocument.value = resp.whoIs.didDocument;
    authorized.value = true;
  }
  return resp;
}