nbpCustomToast function

void nbpCustomToast({
  1. required BuildContext context,
  2. required String message,
  3. Duration duration = const Duration(seconds: 2),
  4. Color backgroundColor = Colors.black87,
  5. Color textColor = Colors.white,
  6. double bottomOffset = 100,
  7. bool isShowRightIcon = true,
})

Implementation

void nbpCustomToast({
  required BuildContext context,
  required String message,
  Duration duration = const Duration(seconds: 2),
  Color backgroundColor = Colors.black87,
  Color textColor = Colors.white,
  double bottomOffset = 100,
  bool isShowRightIcon = true,
}) {
  final overlay = Overlay.of(context);
  OverlayEntry? overlayEntry;

  overlayEntry = OverlayEntry(
    builder: (context) => Positioned(
      bottom: bottomOffset,
      left: 24,
      right: 24,
      child: Material(
        color: Colors.transparent,
        child: AnimatedOpacityToast(
          message,
          backgroundColor,
          textColor,
          isShowRightIcon: isShowRightIcon,
          onDismissed: () {
            overlayEntry?.remove();
          },
        ),
      ),
    ),
  );

  overlay.insert(overlayEntry);
}