getHttpAuthCredentials method

Future<List<URLCredential>> getHttpAuthCredentials({
  1. required URLProtectionSpace protectionSpace,
})

Gets all the HTTP auth credentials saved for that protectionSpace.

Implementation

Future<List<URLCredential>> getHttpAuthCredentials(
    {required URLProtectionSpace protectionSpace}) async {
  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent("host", () => protectionSpace.host);
  args.putIfAbsent("protocol", () => protectionSpace.protocol);
  args.putIfAbsent("realm", () => protectionSpace.realm);
  args.putIfAbsent("port", () => protectionSpace.port);
  List<dynamic> credentialList =
      await _channel.invokeMethod('getHttpAuthCredentials', args);
  List<URLCredential> credentials = [];
  for (Map<dynamic, dynamic> map in credentialList) {
    var credential = URLCredential.fromMap(map.cast<String, dynamic>());
    if (credential != null) {
      credentials.add(credential);
    }
  }
  return credentials;
}