fromJson static method

ConsoleSettings? fromJson(
  1. dynamic value
)

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

Implementation

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

    return ConsoleSettings(
      appsInAnyNamespaceEnabled: mapValueOfType<bool>(json, r'appsInAnyNamespaceEnabled'),
      dexConfig: ConsoleSettingsDexConfig.fromJson(json[r'dexConfig']),
      execEnabled: mapValueOfType<bool>(json, r'execEnabled'),
      googleAnalytics: ConsoleSettingsGoogleAnalytics.fromJson(json[r'googleAnalytics']),
      help: ConsoleSettingsHelp.fromJson(json[r'help']),
      hydratorEnabled: mapValueOfType<bool>(json, r'hydratorEnabled'),
      kustomizeVersions: json[r'kustomizeVersions'] is Iterable
          ? (json[r'kustomizeVersions'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      oidcConfig: mapValueOfType<Object>(json, r'oidcConfig'),
      plugins: json[r'plugins'] is Iterable
          ? (json[r'plugins'] as Iterable).cast<Object>().toList(growable: false)
          : const [],
      statusBadgeEnabled: mapValueOfType<bool>(json, r'statusBadgeEnabled'),
      statusBadgeRootUrl: mapValueOfType<String>(json, r'statusBadgeRootUrl'),
      syncWithReplaceAllowed: mapValueOfType<bool>(json, r'syncWithReplaceAllowed'),
      uiBannerContent: mapValueOfType<String>(json, r'uiBannerContent'),
      uiCssURL: mapValueOfType<String>(json, r'uiCssURL'),
      url: mapValueOfType<String>(json, r'url'),
      userLoginsDisabled: mapValueOfType<bool>(json, r'userLoginsDisabled'),
    );
  }
  return null;
}