dismiss method

Future<T?> dismiss([
  1. T? result
])

Dismisses the flushbar causing is to return a future containing result. When this future finishes, it is guaranteed that Flushbar was dismissed.

Implementation

Future<T?> dismiss([T? result]) async {
  // If route was never initialized, do nothing
  if (flushbarRoute == null) {
    return null;
  }

  if (flushbarRoute!.isCurrent) {
    flushbarRoute!.navigator!.pop(result);
    return flushbarRoute!.completed;
  } else if (flushbarRoute!.isActive) {
    // removeRoute is called every time you dismiss a Flushbar that is not the top route.
    // It will not animate back and listeners will not detect FlushbarStatus.IS_HIDING or FlushbarStatus.DISMISSED
    // To avoid this, always make sure that Flushbar is the top route when it is being dismissed
    flushbarRoute!.navigator!.removeRoute(flushbarRoute!);
  }

  return null;
}