fromMap static method

URLProtectionSpace? fromMap(
  1. Map<String, dynamic>? map, {
  2. EnumMethod? enumMethod,
})

Gets a possible URLProtectionSpace instance from a Map value.

Implementation

static URLProtectionSpace? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = URLProtectionSpace(
    authenticationMethod: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue =>
        URLProtectionSpaceAuthenticationMethod.fromNativeValue(
          map['authenticationMethod'],
        ),
      EnumMethod.value => URLProtectionSpaceAuthenticationMethod.fromValue(
        map['authenticationMethod'],
      ),
      EnumMethod.name => URLProtectionSpaceAuthenticationMethod.byName(
        map['authenticationMethod'],
      ),
    },
    distinguishedNames: _distinguishedNamesDeserializer(
      map['distinguishedNames'],
      enumMethod: enumMethod,
    ),
    host: map['host'],
    iosAuthenticationMethod: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue =>
        IOSNSURLProtectionSpaceAuthenticationMethod.fromNativeValue(
          map['authenticationMethod'],
        ),
      EnumMethod.value =>
        IOSNSURLProtectionSpaceAuthenticationMethod.fromValue(
          map['authenticationMethod'],
        ),
      EnumMethod.name => IOSNSURLProtectionSpaceAuthenticationMethod.byName(
        map['authenticationMethod'],
      ),
    },
    iosDistinguishedNames: _distinguishedNamesDeserializer(
      map['distinguishedNames'],
      enumMethod: enumMethod,
    ),
    iosProxyType: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue =>
        IOSNSURLProtectionSpaceProxyType.fromNativeValue(map['proxyType']),
      EnumMethod.value => IOSNSURLProtectionSpaceProxyType.fromValue(
        map['proxyType'],
      ),
      EnumMethod.name => IOSNSURLProtectionSpaceProxyType.byName(
        map['proxyType'],
      ),
    },
    iosReceivesCredentialSecurely: map['receivesCredentialSecurely'],
    port: map['port'],
    protocol: map['protocol'],
    proxyType: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => URLProtectionSpaceProxyType.fromNativeValue(
        map['proxyType'],
      ),
      EnumMethod.value => URLProtectionSpaceProxyType.fromValue(
        map['proxyType'],
      ),
      EnumMethod.name => URLProtectionSpaceProxyType.byName(map['proxyType']),
    },
    realm: map['realm'],
    receivesCredentialSecurely: map['receivesCredentialSecurely'],
    sslCertificate: SslCertificate.fromMap(
      map['sslCertificate']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    sslError: SslError.fromMap(
      map['sslError']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
  );
  return instance;
}