uiaRequestBackground<T> method

Future<T> uiaRequestBackground<T>(
  1. Future<T> request(
    1. AuthenticationData? auth
    )
)

Run any request and react on user interactive authentication flows here.

Implementation

Future<T> uiaRequestBackground<T>(
    Future<T> Function(AuthenticationData? auth) request) {
  final completer = Completer<T>();
  UiaRequest? uia;
  uia = UiaRequest(
    request: request,
    onUpdate: (state) {
      if (uia != null) {
        if (state == UiaRequestState.done) {
          completer.complete(uia.result);
        } else if (state == UiaRequestState.fail) {
          completer.completeError(uia.error!);
        } else {
          onUiaRequest.add(uia);
        }
      }
    },
  );
  return completer.future;
}