findOne method

Future<T?> findOne({
  1. required bool filter(
    1. T
    ),
})

Retrieves a single model of type T that satisfies the given filter.

filter: The filtering criteria function.

Returns: A model of type T or null if not found.

Implementation

Future<T?> findOne({
  required bool Function(T) filter,
}) async {
  final models = await list();

  return models.firstWhereOrNull(filter);
}