existItem method
API to check the item is existing or not.
Parameters:
id Unique ID to be checked.
Exceptions:
Throws an ArgumentError if ID is empty.
Return 'true' or 'false'
Implementation
bool existItem(String id)
{
if (id.isEmpty) {
throw ArgumentError("You must set id.");
}
else if(items!.isEmpty) {
throw ArgumentError("You don't have any item.");
}
else {
final index = items!.indexWhere((items) => items.id == id);
if (index==-1)
return false;
return true;
}
}