withRedrawSuspended<T> method

Future<T> withRedrawSuspended<T>(
  1. Future<T> action(), {
  2. bool refreshAfter = true,
})

Run action while redraw is disabled, then restore and refresh.

Implementation

Future<T> withRedrawSuspended<T>(
  Future<T> Function() action, {
  bool refreshAfter = true,
}) async {
  await setRedraw(false);
  try {
    return await action();
  } finally {
    await setRedraw(true);
    if (refreshAfter) {
      await refresh();
    }
  }
}