ltrim function
Removes the given chars from the start of the string.
If chars is null, leading whitespace is removed.
Example:
ltrim(' hello'); // 'hello'
ltrim('xxhello', 'x'); // 'hello'
Implementation
String ltrim(String str, [String? chars]) {
if (chars == null) return str.trimLeft();
final set = chars.split('').toSet();
var start = 0;
while (start < str.length && set.contains(str[start])) {
start++;
}
return str.substring(start);
}