fromFile static method

Future<HopConfig> fromFile(
  1. dynamic file
)

Implementation

static Future<HopConfig> fromFile(file) async {
  String content;
  try {
    content = await rootBundle.loadString(file);
  } catch (_) {
    throw ConfigNotFound("Config file \"$file\" not found...");
  }
  YamlMap yaml;
  try {
    yaml = loadYaml(content);
  } catch (_) {
    throw InvalidConfig("Config file \"$file\" has an invalid syntax...");
  }
  return HopConfig.fromJson(yaml);
}