splitByShorter method

List<String> splitByShorter({
  1. required String bigger,
  2. required String shorter,
})

Split the larger element, so that it fits in length to the shorter element, returns a list with the bigger element cut, the shorter element and if it exists, the first residue char of the bigger.

Implementation

List<String> splitByShorter(
    {required String bigger, required String shorter}) {
  var limit = shorter.length;
  var response = <String>[];

  response.add(bigger.substring(0, limit));
  response.add(bigger.substring(limit));

  if (limit != 0) {
    response.add(shorter.substring(0, limit));
  }

  return response;
}