read method
Implementation
@override
Future<String> read(
String sampleName, {
List<String> args = const [],
Map<String, String> namedArgs = const {},
}) async {
var content = (sampleMapping[sampleName] ?? ['']).join('\n');
if (content.isEmpty) {
throw const ReaderFailure(cause: 'target sample is empty');
}
for (var i = 0; i < args.length; i++) {
content = content.replaceFirst('{*}', args[i]);
}
for (var i = 0; i < namedArgs.keys.length; i++) {
content = content.replaceAll(
'{${namedArgs.keys.elementAt(i)}}',
namedArgs[namedArgs.keys.elementAt(i)] ?? '',
);
}
return '$content\n';
}