showQudsToast function
Future
showQudsToast(
- BuildContext context, {
- MainAxisAlignment alignment = MainAxisAlignment.center,
- Widget? content,
- List<
Widget> ? leadingActions, - List<
Widget> ? trailingActions, - Color? backgroundColor,
- Color? shadowColor,
- Duration? displayDuration,
- QudsToastTime? toastTime = QudsToastTime.Normal,
Show customizable buatiful toast.
Implementation
Future showQudsToast(BuildContext context,
{MainAxisAlignment alignment = MainAxisAlignment.center,
Widget? content,
List<Widget>? leadingActions,
List<Widget>? trailingActions,
Color? backgroundColor,
Color? shadowColor,
Duration? displayDuration,
QudsToastTime? toastTime = QudsToastTime.Normal}) async {
var theme = Theme.of(context);
var backColor = backgroundColor ?? theme.primaryColor.withOpacity(0.75);
var shColor = shadowColor ?? Colors.black54;
Widget snackContent = Row(
mainAxisAlignment: alignment,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
boxShadow: [BoxShadow(color: shColor, blurRadius: 5)],
color: backColor),
child: Material(
color: Colors.transparent,
child: Container(
padding: const EdgeInsets.all(6),
child: IntrinsicHeight(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (leadingActions != null) ...[
...leadingActions,
const SizedBox(
width: 5,
)
],
DefaultTextStyle(
style: theme.primaryTextTheme.bodyLarge!
.copyWith(fontSize: 18),
child: content ??
const SizedBox(
width: 5,
height: 5,
)),
if (trailingActions != null) ...[
const SizedBox(
width: 5,
),
...trailingActions
],
],
)))))
],
);
snackContent = DefaultTextStyle(
style: theme.primaryTextTheme.bodyLarge!.copyWith(fontSize: 18),
child: snackContent);
snackContent = IconTheme(data: theme.primaryIconTheme, child: snackContent);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: displayDuration ??
_getToastDuration(toastTime) ??
_getToastDuration(QudsToastTime.Normal)!,
content: snackContent,
backgroundColor: Colors.transparent,
elevation: 0,
),
);
}