combineStringsAndPlaceholders static method
StringMessage
combineStringsAndPlaceholders()
Implementation
static StringMessage combineStringsAndPlaceholders(
List<StringMessage> submessages,
String? id,
List<({int afterStringMessage, int argIndex})> placeholders,
) {
final argPositions = <({int argIndex, int stringIndex})>[];
final s = StringBuffer();
for (var i = 0; i < submessages.length + 1; i++) {
placeholders
.where((element) => element.afterStringMessage == i)
.forEach((element) {
argPositions.add((argIndex: element.argIndex, stringIndex: s.length));
});
if (i < submessages.length) {
final submessage = submessages[i];
s.write(submessage.value);
}
}
return StringMessage(s.toString(), argPositions: argPositions, id: id);
}