splitAtString function

List<String> splitAtString(
  1. int n,
  2. String s
)

Split string into two.

Implementation

List<String> splitAtString(int n, String s) {
  if (n <= 0) {
    return ['', s];
  }
  if (n >= s.length) {
    return [s, ''];
  }
  return [s.substring(0, n), s.substring(n, s.length)];
}