Change toast

This commit is contained in:
problematicconsumer
2023-11-09 16:28:43 +03:30
parent 38f48e07d5
commit c1491ffe0b
5 changed files with 75 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:toastification/toastification.dart';
class CustomAlertDialog extends StatelessWidget {
const CustomAlertDialog({
@@ -49,7 +49,17 @@ class CustomAlertDialog extends StatelessWidget {
}
}
enum AlertType { info, error, success }
enum AlertType {
info,
error,
success;
ToastificationType get _toastificationType => switch (this) {
success => ToastificationType.success,
error => ToastificationType.error,
info => ToastificationType.info,
};
}
class CustomToast extends StatelessWidget {
const CustomToast(
@@ -105,11 +115,18 @@ class CustomToast extends StatelessWidget {
}
void show(BuildContext context) {
final fToast = FToast().init(context);
fToast.showToast(
child: this,
gravity: ToastGravity.BOTTOM,
toastDuration: duration,
toastification.show(
context: context,
title: message,
type: type._toastificationType,
alignment: Alignment.bottomLeft,
autoCloseDuration: duration,
style: ToastificationStyle.fillColored,
pauseOnHover: true,
showProgressBar: false,
dragToClose: true,
closeOnClick: true,
closeButtonShowType: CloseButtonShowType.onHover,
);
}
}