tryRemoveWhere method

RxResult<void> tryRemoveWhere(
  1. bool predicate(
    1. K key,
    2. V value
    )
)

Remove where with error handling

Implementation

RxResult<void> tryRemoveWhere(bool Function(K key, V value) predicate) {
  return RxResult.tryExecute(() {
    final newMap = Map<K, V>.from(value);
    final sizeBefore = newMap.length;
    newMap.removeWhere(predicate);
    if (sizeBefore != newMap.length) value = newMap;
  }, 'remove where from map');
}