trimListOfStrings function

List<String> trimListOfStrings(
  1. List<String> list
)

Apply String.trim to each String of list. Returns the same list instance without change it's length.

Implementation

List<String> trimListOfStrings(List<String> list) {
  final length = list.length;
  for (var i = 0; i < length; ++i) {
    var e = list[i];
    var e2 = e.trim();
    if (e2.length != e.length) {
      list[i] = e2;
    }
  }
  return list;
}