removeSuffix method

  1. @useResult
String removeSuffix(
  1. String suffix
)

Removes suffix from the end if present; otherwise returns this. Audited: 2026-06-12 11:26 EDT

Implementation

@useResult
String removeSuffix(String suffix) =>
    // Code-unit `substring` for the same reason as removePrefix above.
    endsWith(suffix) ? substring(0, length - suffix.length) : this;