variableMessage method
String
variableMessage({
- required String text,
- List<
RegExpReplace> ? regexpReplaces, - bool isThrowOnError = false,
Implementation
String variableMessage({
required String text,
List<RegExpReplace>? regexpReplaces,
bool isThrowOnError = false,
}) {
regexpReplaces ??= regexp_replaces;
try {
String message = "";
message = text;
for (var i = 0; i < regexpReplaces.length; i++) {
RegExpReplace regExpReplace = regexpReplaces[i];
try {
message = message.replaceAllMapped(
regExpReplace.from, regExpReplace.replace);
} catch (e) {
if (isThrowOnError) {
rethrow;
}
}
}
return message;
} catch (e) {
if (isThrowOnError) {
rethrow;
}
return text;
}
}