27 lines
857 B
Dart
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,
|
|
);
|
|
}
|