toPlural method

String toPlural(
  1. int length, [
  2. bool showLength = true
])

Returns a pluralized version of the string based on length.

If showLength is true, prepends the number.

Implementation

String toPlural(int length, [bool showLength = true]) {
  return '${showLength ? "$length" : ""} $this${length > 1 && !endsWith("s")
      ? endsWith("y")
          ? "ies"
          : "s"
      : ""}';
}