finish static method

String finish(
  1. String value,
  2. String cap
)

Caps value with a single instance of cap.

Implementation

static String finish(String value, String cap) {
  if (cap.isEmpty) return value;
  final stripped = value.replaceAll(RegExp(RegExp.escape(cap) + r'+$'), '');
  return '$stripped$cap';
}