format method
Format a string.
Implementation
String format(List<Object> args) {
if (this == null) {
throw ArgumentError('string: $this');
}
return this!.replaceAllMapped(RegExp(r'\{(\d+)\}'), (match) {
final index = int.parse(match.group(1)!);
if (index < 0 || index >= args.length) {
throw ArgumentError('index: $index, length: ${args.length}');
}
return args[index].toString();
});
}