showToastSuccess function
void
showToastSuccess({
- required String message,
- required BuildContext context,
- Color? backgroundColor,
- bool showButton = false,
- ToastGravity? gravity,
- Duration? duration,
- EdgeInsetsGeometry? containerPadding,
- Decoration? containerDecoration,
- String? buttonText,
Implementation
void showToastSuccess(
{required String message,
required BuildContext context,
Color? backgroundColor,
bool showButton = false,
ToastGravity? gravity,
Duration? duration,
EdgeInsetsGeometry? containerPadding,
Decoration? containerDecoration,
String? buttonText}) {
FToast fToast;
fToast = FToast();
fToast.init(context);
Widget toast = Container(
padding: containerPadding ?? const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
decoration: containerDecoration ??
BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
color: backgroundColor ?? Colors.green.shade300,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: Text(
message,
style: const TextStyle(color: Colors.white),
)),
if (showButton)
TextButton(
onPressed: () {
fToast.removeCustomToast();
},
style: TextButton.styleFrom(foregroundColor: Colors.white),
child: Text(buttonText ?? "OK"),
)
],
),
);
fToast.removeCustomToast();
fToast.showToast(
child: toast,
gravity: gravity ?? ToastGravity.BOTTOM,
toastDuration: duration ?? const Duration(seconds: 5),
);
}