createAsync<T> static method

Future<Response<T>> createAsync<T>({
  1. required Future<T> builder(),
  2. required bool isError(
    1. T
    ),
  3. ErrorDetails? error,
})

Implementation

static Future<Response<T>> createAsync<T>({
  required Future<T> Function() builder,
  required bool Function(T) isError,
  ErrorDetails? error,
}) async {
  var payload = await builder();
  if (isError(payload)) {
    return Responses.failure([error ?? ErrorDetails(id: 0)]);
  }
  return Responses.success<T>(payload);
}