Interpolator constructor
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.
Implementation
factory Interpolator(String format, [Map<String?, dynamic> defaultVal = const {}]){
//Escape the braces
const escapeChar = {"pre": "{", "suf": "}"};
return Interpolator.noEscape(format, {}..addAll(escapeChar)..addAll(defaultVal));
}