interpolateAsync static method
Future<String>
interpolateAsync(
- String input,
- ConsumerSupplierFunction<
String, Future< callbackString?> >
Interpolate {} tokens in the input string, but asynchronously
Implementation
static Future<String> interpolateAsync(String input, ConsumerSupplierFunction<String, Future<String?> > callback) async
{
StringBuffer replaced = new StringBuffer();
int currentIndex = 0;
for (Match match in _INTERPOLATE_REGEXP.allMatches(input))
{
String prefix = match.input.substring(currentIndex, match.start);
currentIndex = match.end;
replaced.write(prefix);
String key = match.group(1)!;
replaced.write( await callback(key) ?? ella.EMPTY_STRING );
}
replaced.write(input.substring(currentIndex));
return replaced.toString();
}