deleteFromCollectionWhere<T> static method

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

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

Implementation

static Future deleteFromCollectionWhere<T>(bool Function(dynamic 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);
}