firstNChars method

String firstNChars({
  1. int n = 1,
})

this will give first n characters of string

Implementation

String firstNChars({int n = 1}) {
  if (n > length || n < 1) return this;
  return substring(0, n);
}