removeTrailingComma static method

String? removeTrailingComma(
  1. String? input
)

Removes the trailing comma from the given input string, if present.

Returns the modified string or null if input is null.

Implementation

static String? removeTrailingComma(String? input) {
  if (input != null) {
    if (input.endsWith(',')) {
      return input.substring(0, input.length - 1);
    } else {
      return input;
    }
  }
  return null;
}