addToStash method
Adds the terms
to the Stash and shows a message indicating the addition.
Implementation
void addToStash({
required List<String> terms,
}) async {
if (terms.isEmpty) {
return;
}
bool hasNonEmpty = false;
for (String term in terms) {
if (term.trim().isNotEmpty) {
hasNonEmpty = true;
}
}
if (!hasNonEmpty) {
return;
}
for (String term in terms) {
addToSearchHistory(
historyKey: stashKey,
searchTerm: term,
);
}
if (terms.length == 1) {
Fluttertoast.showToast(
msg: t.stash_added_single(term: terms.first),
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
);
} else {
Fluttertoast.showToast(
msg: t.stash_added_multiple,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
);
}
}