rtrim function

String rtrim(
  1. String str, [
  2. String? chars
])

trim characters from the right-side of the input

Implementation

String rtrim(String str, [String? chars]) {
  var pattern = chars != null ? new RegExp('[$chars]+\$') : new RegExp(r'\s+$');
  return str.replaceAll(pattern, '');
}