replaceVariables static method
String
replaceVariables(
- String text, {
- List<
RichTextPlaceholder> placeholders = const [], - String placeholderMarker = "\\\$",
substitutes the variables occuring in text
with their respective values
stored in placeholders
Implementation
static String replaceVariables(
String text, {
List<RichTextPlaceholder> placeholders = const [],
String placeholderMarker = "\\\$",
}) {
for (RichTextPlaceholder placeholder in placeholders) {
String search =
"$placeholderMarker${placeholder.symbol}$placeholderMarker";
text = text.replaceAll(
RegExp(search),
placeholder.value,
);
}
return text;
}