showWcAlert function

void showWcAlert(
  1. BuildContext context,
  2. WcBaseError error, {
  3. Color backgroundColor = Colors.deepPurple,
  4. Color textColor = Colors.white,
  5. int durationSeconds = 3,
})

Implementation

void showWcAlert(
  BuildContext context,
  WcBaseError error, {
  Color backgroundColor = Colors.deepPurple,
  Color textColor = Colors.white,
  int durationSeconds = 3,
}) {
  final overlay = Overlay.of(context);
  final overlayEntry = OverlayEntry(
    builder: (context) => Positioned(
      top: 0,
      left: 0,
      right: 0,
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 9),
        child: WcAlert(
          error: error,
          backgroundColor: backgroundColor,
          textColor: textColor,
        ),
      ),
    ),
  );

  overlay.insert(overlayEntry);

  Future.delayed(Duration(seconds: durationSeconds), overlayEntry.remove);
}