showWcModal function
void
showWcModal(
- BuildContext context,
- WcBaseError error, {
- Color backgroundColor = Colors.deepPurple,
- Color textColor = Colors.white,
- IconData icon = Icons.error_outline,
- Color iconColor = Colors.white,
- int durationSeconds = 3,
- double height = 300,
- double width = 200,
- Alignment alignment = Alignment.center,
- VoidCallback? onPressed,
Implementation
void showWcModal(
BuildContext context,
WcBaseError error, {
Color backgroundColor = Colors.deepPurple,
Color textColor = Colors.white,
IconData icon = Icons.error_outline,
Color iconColor = Colors.white,
int durationSeconds = 3,
double height = 300,
double width = 200,
Alignment alignment = Alignment.center,
VoidCallback? onPressed,
}) {
final overlay = Overlay.of(context);
late OverlayEntry overlayEntry;
overlayEntry = OverlayEntry(
builder: (context) => Align(
alignment: alignment,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
width: width,
height: height,
child: WcModal(
error: error,
backgroundColor: backgroundColor,
textColor: textColor,
icon: icon,
iconColor: iconColor,
onPressed: () {
if (onPressed != null) {
onPressed();
}
if (overlayEntry.mounted) {
overlayEntry.remove();
}
},
),
),
),
),
);
overlay.insert(overlayEntry);
Future.delayed(Duration(seconds: durationSeconds), () {
if (overlayEntry.mounted) {
overlayEntry.remove();
}
});
}