timerDialog function

Future<void> timerDialog(
  1. BuildContext context,
  2. AlertDialog dialog
)

Implementation

Future<void> timerDialog(BuildContext context, AlertDialog dialog) async {
  const displayTime = Duration(seconds: 2);
  try {
    await showDialog(
      context: context,
      barrierColor: Colors.white10,
      builder: (context) {
        return dialog;
      },
    ).timeout(displayTime);
  } on TimeoutException {
    // ignore: use_build_context_synchronously
    Navigator.of(context).pop();
  }
}