getConfig method Null safety

  1. @override
Future<Config> getConfig(
  1. String path
)
override

Gets the database configuration through the yaml file defined in it's parameter path (String)

Implementation

@override
Future<Config> getConfig(String path) async {
  final yaml = File(path);
  late Map doc;
  if (yaml.existsSync()) {
    doc = loadYaml(await File(path).readAsString());
  } else {
    doc = loadYaml('''
name: Dartion Server
port: 3031
db: db.json
host: 0.0.0.0
''');
  }

  return Config.fromYaml(doc);
}