onChanged method

void onChanged(
  1. String? value
)

Implementation

void onChanged(String? value) async {
  var _last = value ?? '';
  last = _last;
  var isHash = _last.startsWith(hashtagSymbol);
  var isMention = _last.startsWith(mentionSymbol);
  if (_last.isNotEmpty && (isHash || isMention)) {
    if (_last.length == 1) {
      clear(
          hash: isMention ? null : initalTags,
          people: isHash ? null : intialMentions);
    } else if (isMention) {
      var temp = onSearchMention != null && _last.length > 1
          ? await onSearchMention!(_last.split(mentionSymbol)[1])
          : intialMentions?.where((e) => e.title.contains(_last)).toList();
      clear(people: temp ?? []);
    } else if (isHash) {
      var temp = onSearchTags != null
          ? await onSearchTags!(_last)
          : initalTags?.where((e) => e.hashtag.contains(_last)).toList();
      clear(hash: temp);
    }
  } else {
    clear();
  }
  last = value;
}