addItemsFromController method
- TextEditingController controller, {
- bool clearController = true,
Adds all the non-already existing items from the controller.
The item separator is the comma.
Implementation
bool addItemsFromController(
TextEditingController controller, {
bool clearController = true,
}) {
try {
_itemsBeforeLastAddition = List<String>.from(_terms);
final List<String> input = controller.text.split(',');
bool result = false;
for (final String item in input) {
if (addTerm(item.trim())) {
result = true;
}
}
if (result && clearController) {
controller.text = '';
}
return result;
} catch (_) {
/// The field was not initialized
return false;
}
}