updateItem method

void updateItem(
  1. bool test(
    1. T item
    ),
  2. T updatedItem
)

Implementation

void updateItem(bool Function(T item) test, T updatedItem) {
  if (state is! ListLoaded<T>) return;
  final current = state as ListLoaded<T>;
  final updatedItems = current.items
      .map((item) => test(item) ? updatedItem : item)
      .toList();
  emit(current.copyWith(items: updatedItems));
}