Interpolator class Null safety

Class to parse and cache string template for later interpolation

Initialization with a string template:

const format = "substitution: {sub}; escaping braces: {pre}{suf} placeholder:{unmatched}";
final interpolator = Interpolator(format, {null: "null"});
print(interpolator({"sub": "substituted"}));

//substitution: substituted; escaping braces: {} placeholder:null

Constructors

Interpolator(String format, [Map<String?, dynamic> defaultVal = const {}])
Create an Interpolator with format and an optional map defaultVal to set the default values of keys. Set the value of key null in the defaultVal to designate a placeholder to substitute the keys in the string template which do not exist in the provided map, otherwise a FormatException will be thrown when fail to find a key in the map.
factory
Interpolator.noEscape(String format, [Map<String?, dynamic> defaultVal = const {}])
All the same to the Interpolator constructor except this one crates an interpolator which does not escape the braces.
factory

Properties

format → dynamic
The input string template
read-only
hashCode int
The hash code for this object.
read-onlyinherited
keys → dynamic
Interpolation keys of string template
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

call<V>(Map<String?, V> subs) String
Perform interpolation on early parsed string template with subs
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
retrieve(String input) Map<String, String>
Retrieve values from an interpolated string input Use with care since values may contain the same patterns that divide values
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited