DartParser class
A parser for Dart configuration files in Jetleaf.
This parser supports parsing Dart map literals and variable declarations
to extract configuration data.
It is designed to handle:
final
,const
, orvar
assignments with map literals.- Direct map literals (
{ ... }
). - Nested maps and lists.
- Strings, numbers, booleans, and null values.
- Preservation of special Jetleaf property syntax (
#{}
and@{}
), which are returned as raw strings for later resolution.
Example usage:
void main() {
final parser = DartParser();
const source = '''
final config = {
"host": "localhost",
"port": 8080,
"debug": true,
"nested": {
"feature": "enabled"
},
"list": [1, 2, 3],
"dynamic": "#{someExpression}"
};
''';
final config = parser.parse(source);
print(config['host']); // localhost
print(config['port']); // 8080
print(config['nested']); // {feature: enabled}
print(config['list']); // [1, 2, 3]
print(config['dynamic']); // #{someExpression}
}
Constructors
- DartParser()
- A parser for Dart configuration files in Jetleaf.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
String source) → Map< String, dynamic> -
Parses the given
source
string into aMap<String, dynamic>
.override -
parseAs(
Asset asset) → Object -
Parses the given
Asset
and returns it as a generic Object.inherited -
parseAsset(
Asset asset) → Map< String, dynamic> -
Parses a Jetleaf
Asset
into aMap<String, dynamic>
.override -
parseFile(
String path) → Map< String, dynamic> -
Optionally parses configuration directly from a file located at
path
.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited