fromJson static method

MmConfigFileSettings? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static MmConfigFileSettings? 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 "MmConfigFileSettings[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "MmConfigFileSettings[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return MmConfigFileSettings(
      maxFileSize: mapValueOfType<int>(json, r'MaxFileSize'),
      driverName: mapValueOfType<String>(json, r'DriverName'),
      directory: mapValueOfType<String>(json, r'Directory'),
      enablePublicLink: mapValueOfType<bool>(json, r'EnablePublicLink'),
      publicLinkSalt: mapValueOfType<String>(json, r'PublicLinkSalt'),
      thumbnailWidth: mapValueOfType<int>(json, r'ThumbnailWidth'),
      thumbnailHeight: mapValueOfType<int>(json, r'ThumbnailHeight'),
      previewWidth: mapValueOfType<int>(json, r'PreviewWidth'),
      previewHeight: mapValueOfType<int>(json, r'PreviewHeight'),
      profileWidth: mapValueOfType<int>(json, r'ProfileWidth'),
      profileHeight: mapValueOfType<int>(json, r'ProfileHeight'),
      initialFont: mapValueOfType<String>(json, r'InitialFont'),
      amazonS3AccessKeyId: mapValueOfType<String>(json, r'AmazonS3AccessKeyId'),
      amazonS3SecretAccessKey: mapValueOfType<String>(json, r'AmazonS3SecretAccessKey'),
      amazonS3Bucket: mapValueOfType<String>(json, r'AmazonS3Bucket'),
      amazonS3Region: mapValueOfType<String>(json, r'AmazonS3Region'),
      amazonS3Endpoint: mapValueOfType<String>(json, r'AmazonS3Endpoint'),
      amazonS3SSL: mapValueOfType<bool>(json, r'AmazonS3SSL'),
    );
  }
  return null;
}