addConfigFile method

void addConfigFile(
  1. File configFile
)

Read and add config file into the config map.

Supported file types are yaml and json.

Implementation

void addConfigFile(File configFile) async {
  final stringContent = await configFile.readAsString();
  final ext = extension(configFile.path);
  if (ext == '.yaml' || ext == '.yml') {
    final content = loadYaml(stringContent);
    _merge(_configMap, content);
  } else if (ext == '.json') {
    final content = jsonDecode(stringContent);
    _merge(_configMap, content);
  } else {
    throw Exception('Unknown config file type of file ${configFile.path}. '
        'Supported file types are yaml and json.');
  }
}