showToastNotification function
dynamic
showToastNotification(
- BuildContext context, {
- ToastNotificationStyleType? style,
- String? title,
- IconData? icon,
- String description = "",
- Duration? duration,
Display a new Toast notification to the user. Provide a valid ToastNotificationStyleType i.e ToastNotificationStyleType.SUCCESS Set a title, description to personalise the message.
Implementation
showToastNotification(BuildContext context,
{ToastNotificationStyleType? style,
String? title,
IconData? icon,
String description = "",
Duration? duration}) {
_ToastMeta toastMeta = _ToastNotificationStyleMetaHelper.getValue(style);
toastMeta.title = toastMeta.title;
if (title != null) {
toastMeta.title = title;
}
toastMeta.description = description;
Widget _icon = toastMeta.icon;
if (icon != null) {
_icon = Icon(icon, color: Colors.white);
}
// show the toast notification
showToastWidget(
InkWell(
onTap: () => ToastManager().dismissAll(showAnim: true),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 18.0),
margin: EdgeInsets.symmetric(horizontal: 8.0),
height: 100,
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
color: toastMeta.color,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Pulse(
child: Container(
child: Center(
child: IconButton(
onPressed: () {},
icon: _icon,
padding: EdgeInsets.only(right: 16),
),
),
),
infinite: true,
duration: Duration(milliseconds: 1500),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
toastMeta.title,
style: Theme.of(context)
.textTheme
.headline5!
.copyWith(color: Colors.white),
),
Text(
toastMeta.description,
style: Theme.of(context)
.textTheme
.bodyText1!
.copyWith(color: Colors.white),
),
],
),
),
],
),
),
),
context: context,
isIgnoring: false,
position: StyledToastPosition.top,
animation: StyledToastAnimation.slideFromTopFade,
duration: duration ?? toastMeta.duration,
);
}