autoCloseSnackBar method

void autoCloseSnackBar()

Automatically closes the SnackBar after the specified autoCloseDuration if autoClose is set to true.

Implementation

void autoCloseSnackBar() {
  if (widget.autoClose) {
    Future.delayed(widget.autoCloseDuration).then((_) {
      if (!mounted) return;
      if (Navigator.of(context).canPop()) {
        Navigator.of(context).pop();
      }
    });
  }
}