parse method
Parses the given source
string into a Map<String, dynamic>
.
Implementations must:
- Convert the raw string into structured key-value pairs.
- Return a valid map representation.
- Throw a FormatException if parsing fails due to invalid syntax or unexpected input.
Example:
final config = parser.parse('{"debug": true}');
print(config['debug']); // true
Implementation
@override
Map<String, dynamic> parse(String source) {
try {
final normalized = _normalizeNewlines(source);
return _parseLines(normalized);
} catch (e) {
throw ParserException('Failed to parse ENV: $e');
}
}