optionalSingle<T> method

T? optionalSingle<T>(
  1. bool conditionHandler(
    1. T element
    )
)

Implementation

T? optionalSingle<T>(
  bool Function(T element) conditionHandler,
) {
  for (var item in this) {
    final stateIterator = conditionHandler(item);

    if (!stateIterator) {
      continue;
    }

    return item;
  }

  return null;
}