then<R> method

void then<R>(
  1. VoidCallback onValue, {
  2. Function? onError,
})

回调

Implementation

void then<R>(VoidCallback onValue, {Function? onError}) {
  if (isComplete) {
    if (isError && onError != null) {
      onError(error);
    } else {
      onValue(result);
    }
  } else {
    (_callback ??= []).add(onValue);
    if (onError != null) {
      (_onError ??= []).add(onError);
    }
  }
}