StackSettings.fromJson constructor

StackSettings.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory StackSettings.fromJson(Map<String, dynamic> json) {
  final canonical = Map<String, dynamic>.from(json);
  if (canonical.containsKey('secretsprovider')) {
    canonical['secretsProvider'] = canonical['secretsprovider'];
    canonical.remove('secretsprovider');
  }
  if (canonical.containsKey('encryptedkey')) {
    canonical['encryptedKey'] = canonical['encryptedkey'];
    canonical.remove('encryptedkey');
  }
  if (canonical.containsKey('encryptionsalt')) {
    canonical['encryptionSalt'] = canonical['encryptionsalt'];
    canonical.remove('encryptionsalt');
  }

  final extras = Map<String, dynamic>.from(canonical)
    ..remove('secretsProvider')
    ..remove('encryptedKey')
    ..remove('encryptionSalt')
    ..remove('config');

  return StackSettings(
    secretsProvider: canonical['secretsProvider'] == null
        ? null
        : '${canonical['secretsProvider']}',
    encryptedKey: canonical['encryptedKey'] == null
        ? null
        : '${canonical['encryptedKey']}',
    encryptionSalt: canonical['encryptionSalt'] == null
        ? null
        : '${canonical['encryptionSalt']}',
    config: canonical['config'] is Map
        ? (canonical['config'] as Map).map(
            (key, value) => MapEntry('$key', value),
          )
        : null,
    extras: extras,
  );
}