showAlertBanner function
dynamic
showAlertBanner(
- BuildContext context,
- VoidCallback onTap,
- Widget child, {
- AlertBannerLocation alertBannerLocation = AlertBannerLocation.top,
- double? maxLength,
- Duration? durationOfStayingOnScreen,
- Duration? durationOfScalingUp,
- Duration? durationOfScalingDown,
- Duration? durationOfLeavingScreenBySwipe,
- Curve? curveScaleUpAnim,
- Curve? curveScaleDownAnim,
- Curve? curveTranslateAnim,
- bool safeAreaTopEnabled = true,
- bool safeAreaBottomEnabled = true,
- bool safeAreaLeftEnabled = true,
- bool safeAreaRightEnabled = true,
Implementation
dynamic showAlertBanner(
BuildContext context,
VoidCallback onTap,
Widget child, {
AlertBannerLocation alertBannerLocation = AlertBannerLocation.top,
double? maxLength,
Duration? durationOfStayingOnScreen,
Duration? durationOfScalingUp,
Duration? durationOfScalingDown,
Duration? durationOfLeavingScreenBySwipe,
Curve? curveScaleUpAnim,
Curve? curveScaleDownAnim,
Curve? curveTranslateAnim,
bool safeAreaTopEnabled = true,
bool safeAreaBottomEnabled = true,
bool safeAreaLeftEnabled = true,
bool safeAreaRightEnabled = true,
}) {
OverlayEntry? overlay;
overlay = OverlayEntry(
builder: (context) {
return Align(
alignment: alertBannerLocation == AlertBannerLocation.top
? Alignment.topCenter
: Alignment.bottomCenter,
child: SafeArea(
top: safeAreaTopEnabled,
bottom: safeAreaBottomEnabled,
left: safeAreaLeftEnabled,
right: safeAreaRightEnabled,
child: _OverlayItem(
onTap: onTap,
curveScaleDownAnim: curveScaleDownAnim ?? Curves.decelerate,
curveScaleUpAnim: curveScaleUpAnim ?? Curves.easeOutBack,
curveTranslateAnim: curveTranslateAnim ?? Curves.ease,
durationOfScalingUp:
durationOfScalingUp ?? const Duration(milliseconds: 400),
durationOfScalingDown:
durationOfScalingDown ?? const Duration(milliseconds: 250),
durationOfLeavingScreenBySwipe: durationOfLeavingScreenBySwipe ??
const Duration(milliseconds: 1500),
alertBannerLocation: alertBannerLocation,
maxWidth: maxLength,
overlay: overlay,
duration:
durationOfStayingOnScreen ?? const Duration(milliseconds: 3500),
child: child,
),
),
);
},
);
Overlay.of(context)?.insert(overlay);
}