deleteFromCollectionWhere<T> static method

Future deleteFromCollectionWhere<T>(
  1. bool where(
    1. T value
    ), {
  2. required String key,
})

Delete item(s) from a collection using a where query.

Implementation

static Future deleteFromCollectionWhere<T>(bool Function(T value) where,
    {required String key}) async {
  List<T> collection = await readCollection<T>(key);
  if (collection.isEmpty) return;

  collection.removeWhere((value) => where(value));

  await saveCollection<T>(key, collection);
}