removeStart method
Returns a new string with start removed from the beginning, or null
if the result is empty.
When isCaseSensitive is false, uses case-insensitive matching. When
trimFirst is true, the string is trimmed before checking.
Implementation
@useResult
String? removeStart(
String? start, {
bool isCaseSensitive = true,
bool trimFirst = false,
}) {
if (trimFirst) {
return trim().removeStart(start, isCaseSensitive: isCaseSensitive);
}
if (start == null || start.isEmpty) {
return this;
}
if (isCaseSensitive) {
return startsWith(start) ? substringSafe(start.length).nullIfEmpty() : this;
}
return toLowerCase().startsWith(start.toLowerCase())
? substringSafe(start.length).nullIfEmpty()
: this;
}