fromJson static method

ImapSmtpAccessDetails? fromJson(
  1. dynamic value
)

Returns a new ImapSmtpAccessDetails instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static ImapSmtpAccessDetails? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "ImapSmtpAccessDetails[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "ImapSmtpAccessDetails[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return ImapSmtpAccessDetails(
      secureSmtpServerHost: mapValueOfType<String>(json, r'secureSmtpServerHost')!,
      secureSmtpServerPort: mapValueOfType<int>(json, r'secureSmtpServerPort')!,
      secureSmtpUsername: mapValueOfType<String>(json, r'secureSmtpUsername')!,
      secureSmtpPassword: mapValueOfType<String>(json, r'secureSmtpPassword')!,
      smtpServerHost: mapValueOfType<String>(json, r'smtpServerHost')!,
      smtpServerPort: mapValueOfType<int>(json, r'smtpServerPort')!,
      smtpUsername: mapValueOfType<String>(json, r'smtpUsername')!,
      smtpPassword: mapValueOfType<String>(json, r'smtpPassword')!,
      imapServerHost: mapValueOfType<String>(json, r'imapServerHost')!,
      imapServerPort: mapValueOfType<int>(json, r'imapServerPort')!,
      imapUsername: mapValueOfType<String>(json, r'imapUsername')!,
      imapPassword: mapValueOfType<String>(json, r'imapPassword')!,
    );
  }
  return null;
}