ltrim function

String ltrim(
  1. String str,
  2. [String? chars]
)

trim characters from the left-side of the input

Implementation

String ltrim(String str, [String? chars]) {
  var pattern = chars != null ? new RegExp('^[$chars]+') : new RegExp(r'^\s+');
  return str.replaceAll(pattern, '');
}