asap<T> method

FutureOr<T> asap<T>(
  1. T computation(), {
  2. bool condition()?,
})

Implementation

FutureOr<T> asap<T>(T Function() computation,
    {bool Function()? condition}) async {
  T val;
  if (condition == null || !condition()) {
    await Future.delayed(Duration.zero);
    val = computation();
  } else {
    val = computation();
  }
  return val;
}