removeSuffix method
Removes the suffix from this string if it ends with suffix.
Returns null if this string does not end with suffix.
Examples:
- "test.txt".removeSuffix(".txt") → "test"
- "test".removeSuffix(".txt") → null
Implementation
String? removeSuffix(String suffix) {
if (endsWith(suffix)) {
return substring(0, length - suffix.length);
} else {
return null;
}
}