fromMap static method

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

Gets a possible URLCredential instance from a Map value.

Implementation

static URLCredential? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = URLCredential(
    certificates: _certificatesDeserializer(
      map['certificates'],
      enumMethod: enumMethod,
    ),
    iosCertificates: _certificatesDeserializer(
      map['certificates'],
      enumMethod: enumMethod,
    ),
    iosPersistence: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => IOSURLCredentialPersistence.fromNativeValue(
        map['persistence'],
      ),
      EnumMethod.value => IOSURLCredentialPersistence.fromValue(
        map['persistence'],
      ),
      EnumMethod.name => IOSURLCredentialPersistence.byName(
        map['persistence'],
      ),
    },
    password: map['password'],
    persistence: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => URLCredentialPersistence.fromNativeValue(
        map['persistence'],
      ),
      EnumMethod.value => URLCredentialPersistence.fromValue(
        map['persistence'],
      ),
      EnumMethod.name => URLCredentialPersistence.byName(map['persistence']),
    },
    username: map['username'],
  );
  return instance;
}