words function

List<String> words(
  1. String text, {
  2. bool unique = false,
})

Implementation

List<String> words(String text, {bool unique = false}) {
  var list = text.split(' ').where((e) => e != ' ').toList();
  if (!unique) {
    return list;
  } else {
    List<String> uniqueList = [];
    for (var s in list) {
      if (!uniqueList.contains(s)) {
        uniqueList.add(s);
      }
    }
    return uniqueList;
  }
}