Initial and done prolly
This commit is contained in:
commit
6f88b9966f
175 changed files with 15445 additions and 0 deletions
100
lib/services/toaster_service.dart
Normal file
100
lib/services/toaster_service.dart
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:toastification/toastification.dart';
|
||||
|
||||
class ToasterService extends GetxService {
|
||||
static ToasterService get to => Get.find();
|
||||
|
||||
void show({
|
||||
required String title,
|
||||
required String message,
|
||||
ToastificationType type = ToastificationType.info,
|
||||
ToastificationStyle style = ToastificationStyle.flat,
|
||||
AlignmentGeometry alignment = Alignment.bottomLeft,
|
||||
ToastificationCallbacks callbacks = const ToastificationCallbacks(),
|
||||
Duration? autoCloseDuration = const Duration(seconds: 2),
|
||||
}) {
|
||||
if (Get.context?.mounted != true) return;
|
||||
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
toastification.show(
|
||||
context: Get.context,
|
||||
type: type,
|
||||
style: style,
|
||||
title: Text(title),
|
||||
description: Text(message),
|
||||
alignment: alignment,
|
||||
autoCloseDuration: autoCloseDuration,
|
||||
closeOnClick: false,
|
||||
callbacks: callbacks,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void info({
|
||||
required String title,
|
||||
required String message,
|
||||
ToastificationStyle style = ToastificationStyle.flat,
|
||||
AlignmentGeometry alignment = Alignment.bottomLeft,
|
||||
ToastificationCallbacks callbacks = const ToastificationCallbacks(),
|
||||
Duration? autoCloseDuration = const Duration(seconds: 2),
|
||||
}) {
|
||||
show(
|
||||
title: title,
|
||||
message: message,
|
||||
style: style,
|
||||
alignment: alignment,
|
||||
callbacks: callbacks,
|
||||
autoCloseDuration: autoCloseDuration,
|
||||
);
|
||||
}
|
||||
|
||||
void waring({
|
||||
required String title,
|
||||
required String message,
|
||||
ToastificationStyle style = ToastificationStyle.flat,
|
||||
AlignmentGeometry alignment = Alignment.bottomLeft,
|
||||
ToastificationCallbacks callbacks = const ToastificationCallbacks(),
|
||||
Duration? autoCloseDuration = const Duration(seconds: 2),
|
||||
}) {
|
||||
show(
|
||||
title: title,
|
||||
message: message,
|
||||
style: style,
|
||||
alignment: alignment,
|
||||
callbacks: callbacks,
|
||||
autoCloseDuration: autoCloseDuration,
|
||||
);
|
||||
}
|
||||
|
||||
void success({
|
||||
required String title,
|
||||
required String message,
|
||||
ToastificationStyle style = ToastificationStyle.flat,
|
||||
AlignmentGeometry alignment = Alignment.bottomLeft,
|
||||
ToastificationCallbacks callbacks = const ToastificationCallbacks(),
|
||||
Duration? autoCloseDuration = const Duration(seconds: 2),
|
||||
}) {
|
||||
show(
|
||||
title: title,
|
||||
message: message,
|
||||
type: ToastificationType.success,
|
||||
);
|
||||
}
|
||||
|
||||
void error({
|
||||
required String title,
|
||||
required String message,
|
||||
ToastificationStyle style = ToastificationStyle.flat,
|
||||
AlignmentGeometry alignment = Alignment.bottomLeft,
|
||||
ToastificationCallbacks callbacks = const ToastificationCallbacks(),
|
||||
Duration? autoCloseDuration = const Duration(seconds: 2),
|
||||
}) {
|
||||
show(
|
||||
title: title,
|
||||
message: message,
|
||||
type: ToastificationType.error,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue