showOnDialog static method
dynamic
showOnDialog({
- required BuildContext context,
- required String message,
- Duration duration = const Duration(seconds: 3),
- ActionType action = ActionType.none,
Implementation
static showOnDialog({
required BuildContext context,
required String message,
Duration duration = const Duration(seconds: 3),
ActionType action = ActionType.none,
}) {
OverlayState? overlayState = Overlay.of(context);
OverlayEntry overlayEntry = OverlayEntry(
builder: (context) => Positioned(
bottom: MediaQuery.of(context).viewInsets.bottom,
left: 0,
right: 0,
child: Material(
color: Colors.transparent,
child: Container(
margin: Pad.a12,
decoration: BoxDecoration(
color: action == ActionType.success
? Clr.successColor
: action == ActionType.error
? Clr.errorColor
: Clr.primaryColor,
borderRadius: BR.cSmall,
),
padding: EdgeInsets.symmetric(
horizontal: Dim.d12.w,
vertical: 10.h,
),
child: Text(
message,
style: AppTypography.body.copyWith(
color: Clr.white,
fontWeight: FontWeight.w400,
),
),
),
),
),
);
overlayState.insert(overlayEntry);
Future.delayed(duration, () {
overlayEntry.remove();
});
}