aboutsummaryrefslogtreecommitdiff
path: root/lib/widgets/toastbar_widget.dart
diff options
context:
space:
mode:
authordavidpkj <davidpenkow1@gmail.com>2022-07-17 19:25:26 +0200
committerdavidpkj <davidpenkow1@gmail.com>2022-07-17 19:25:26 +0200
commitd282f4bb380ce9c445d6bd3a4c9f001bb6b5f501 (patch)
tree023428b7fa249b66a34d0d83c2f0df0ea572ba75 /lib/widgets/toastbar_widget.dart
Initial Commit
Diffstat (limited to 'lib/widgets/toastbar_widget.dart')
-rw-r--r--lib/widgets/toastbar_widget.dart27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/widgets/toastbar_widget.dart b/lib/widgets/toastbar_widget.dart
new file mode 100644
index 0000000..760ce2e
--- /dev/null
+++ b/lib/widgets/toastbar_widget.dart
@@ -0,0 +1,27 @@
+import 'package:flutter/material.dart';
+
+class ToastBar {
+ static Future<void> showToastBar(BuildContext context, String content, {bool error = false, String? actionLabel, Function? actionCallback}) async {
+ SnackBar snackBar = SnackBar(
+ action: actionLabel != ""
+ ? SnackBarAction(
+ label: actionLabel!,
+ onPressed: () {
+ if (actionCallback != null) actionCallback();
+ },
+ textColor: Theme.of(context).colorScheme.secondary)
+ : null,
+ backgroundColor: error == true ? Colors.red : Colors.grey[900],
+ behavior: SnackBarBehavior.floating,
+ duration: Duration(seconds: 5),
+ elevation: 5.0,
+ content: Text(
+ content,
+ style: TextStyle(color: Colors.white),
+ overflow: TextOverflow.ellipsis,
+ ),
+ );
+
+ ScaffoldMessenger.of(context).showSnackBar(snackBar);
+ }
+}