format static method
Replaces params in input string
Simply replaces strings with params. For more complex formatting can be better to use Intl.
Set custom ParamDecoratorFormat to decorate param, for example: 'city' => '{city}' or 'city' => '$city'
Default decorator is set to ParamDecorator.curl
'Weather in {city} is {temp}°{symbol}'
Then params are:
{
{'city': 'California'},
{'temp': '25.5'},
{'symbol': 'C'},
}
Returns formatted string.
Implementation
static String format(String input, Map<String, String> params,
[ParamDecoratorFormat? decorator]) {
decorator ??= ParamDecorator.curl;
params.forEach(
(key, value) => input = input.replaceFirst(decorator!(key), value));
return input;
}