removeLastCurlyBrackets method
Removes the last occurrence of curly brackets ('}') from the string.
Returns the modified string after removing the last curly bracket.
Throws an Exception if no curly bracket is found in the string.
Implementation
String removeLastCurlyBrackets() {
final lastIndex = lastIndexOf('}');
if (lastIndex >= 0) {
return replaceFirst('}', '', lastIndex);
} else {
throw Exception('Could not find last }');
}
}