manager-app/lib/Components/message_notification.dart
Thomas Fransolet 205f1ec933 Misc
2026-05-09 00:23:04 +02:00

27 lines
857 B
Dart

import 'package:flutter/material.dart';
import 'package:toastification/toastification.dart';
import 'package:manager_app/constants.dart';
showNotification(Color backgroundColor, Color textColor, String text, BuildContext context, int? duration) {
final ToastificationType type;
if (backgroundColor == kSuccess) {
type = ToastificationType.success;
} else if (backgroundColor == kError) {
type = ToastificationType.error;
} else if (backgroundColor == Colors.orange) {
type = ToastificationType.warning;
} else {
type = ToastificationType.info;
}
toastification.show(
context: context,
type: type,
style: ToastificationStyle.fillColored,
description: Text(text, softWrap: true),
alignment: Alignment.topRight,
autoCloseDuration: Duration(milliseconds: duration ?? 4000),
pauseOnHover: true,
);
}