showTill method

void showTill({
  1. Widget? content,
  2. required Function run,
})

Implementation

void showTill({
  Widget? content,
  required Function run,
}) async {
  SnackBar? snackBar = this.snackBar;

  if (content != null) {
    snackBar = _buildFrom(
      this.snackBar!,
      content: content,
      duration: const Duration(days: 1),
    );
  }

  remove();

  if (snackBar == null) {
    throw Exception("snackBar is null");
  }

  ScaffoldMessenger.of(context!)
    ..hideCurrentSnackBar()
    ..showSnackBar(snackBar);

  try {
    await run();
  } catch (e) {
    remove();
    debugPrint(e.toString());
  } finally {
    remove();
  }
}