custom static method
void
custom(
- BuildContext context, {
- required String message,
- required Color backgroundColor,
- ToastPosition? position,
- Color textColor = Colors.white,
- IconData? icon,
- Duration? duration,
- bool? showCloseButton,
- ToastBehavior? behavior,
- VoidCallback? onTap,
Show custom toast with custom colors
Implementation
static void custom(
BuildContext context, {
required String message,
required Color backgroundColor,
ToastPosition? position,
Color textColor = Colors.white,
IconData? icon,
Duration? duration,
bool? showCloseButton,
ToastBehavior? behavior,
VoidCallback? onTap,
}) {
final config = defaultConfig;
final finalPosition = position ?? config.position;
final finalDuration = duration ?? config.duration;
final finalShowCloseButton = showCloseButton ?? config.showCloseButton;
final finalBehavior = behavior ?? config.behavior;
if (finalBehavior == ToastBehavior.queue) {
_ToastQueue.enqueue(_ToastItem(
context: context,
message: message,
type: ToastType.info, // Dummy type for custom
position: finalPosition,
animation: config.animation,
backgroundColor: backgroundColor,
textColor: textColor,
textStyle: TextStyle(
color: textColor,
fontWeight: FontWeight.w500,
fontSize: 14,
),
showIcon: icon != null,
showCloseButton: finalShowCloseButton,
elevation: config.elevation,
borderRadius: config.borderRadius,
maxWidth: config.maxWidth,
margin: config.margin,
padding: config.padding,
duration: finalDuration,
onTap: onTap,
customIcon: icon,
));
return;
}
_showToastDirect(
context,
message: message,
type: ToastType.info,
position: finalPosition,
animation: config.animation,
duration: finalDuration,
backgroundColor: backgroundColor,
textColor: textColor,
textStyle: TextStyle(
color: textColor,
fontWeight: FontWeight.w500,
fontSize: 14,
),
showIcon: icon != null,
showCloseButton: finalShowCloseButton,
elevation: config.elevation,
borderRadius: config.borderRadius,
maxWidth: config.maxWidth,
margin: config.margin,
padding: config.padding,
onTap: onTap,
customIcon: icon,
);
}