removeStart method
Returns a new string with the specified start
removed from the beginning
of the original string, if it exists.
Implementation
String? removeStart(String? start, {bool isCaseSensitive = true, bool trimFirst = false}) {
// If trimFirst is true, recurse with the trimmed string.
if (trimFirst) {
return trim().removeStart(start, isCaseSensitive: isCaseSensitive);
}
// If start is null or empty, there is nothing to remove.
if (start == null || start.isEmpty) {
return this;
}
// Handle case-sensitive removal.
if (isCaseSensitive) {
return startsWith(start) ? substring(start.length).nullIfEmpty() : this;
}
// Handle case-insensitive removal.
return toLowerCase().startsWith(start.toLowerCase())
? substring(start.length).nullIfEmpty()
: nullIfEmpty();
}