parseFile method

Map<String, dynamic> parseFile(
  1. String path
)

Optionally parses configuration directly from a file located at path.

By default, this method throws a ParserException to indicate that file-based parsing is not supported.
Implementations should override this if file parsing is required.

Example:

final config = parser.parseFile('config.json');
print(config['port']); // e.g. 8080

Implementation

Map<String, dynamic> parseFile(String path) {
  final file = File(path);
  if (!file.existsSync()) {
    throw ParserException('File not found: $path');
  }
  final content = file.readAsStringSync();
  return parse(content);
}