addTerm method

bool addTerm(
  1. String term
)

Returns true if the term was not in the list and then was added.

Implementation

bool addTerm(String term) {
  term = term.trim();
  if (term.isEmpty) {
    return false;
  }
  if (containsTerm(term)) {
    return false;
  }

  final MapEntry<RobotoffQuestion, InsightAnnotation?>? robotoffQuestion =
      _findRobotoffQuestion(term);

  if (robotoffQuestion != null) {
    robotoffQuestionsNotifier
      ..value[robotoffQuestion.key] = InsightAnnotation.YES
      ..notifyListeners();

    _changed = true;
    return true;
  }

  _terms.add(term);
  _changed = _computeHasChanged();
  notifyListeners();
  return true;
}