create<T> static method

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

Implementation

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