showTopAlert method

void showTopAlert()

Implementation

void showTopAlert() async {
  overlayState ??= Overlay.of(context);

  overlayEntry = OverlayEntry(
    builder: (context) {
      return Align(
        alignment: Alignment.topCenter,
        child: Container(
          child: TopBannerWidget(
            overlayEntry,
            color,
            child,
            onTap: onTap,
            closeOnX: closeOnX,
            customKey: key ?? "",
          ),
        ),
      );
    },
  );

  overlayState?.insert(overlayEntry);

  if (duration != Duration.zero) {
    await Future.delayed(
      duration,
    );

    overlayEntry.remove();
  }
}