From 43153f9b0d253c58fab9f4a23b17e4c09986e1b2 Mon Sep 17 00:00:00 2001 From: efrilm Date: Wed, 13 Aug 2025 00:19:17 +0700 Subject: [PATCH] feat: toast --- .../components/toast/flushbar.dart | 43 +++++++++++++++++++ pubspec.lock | 8 ++++ pubspec.yaml | 1 + 3 files changed, 52 insertions(+) create mode 100644 lib/presentation/components/toast/flushbar.dart diff --git a/lib/presentation/components/toast/flushbar.dart b/lib/presentation/components/toast/flushbar.dart new file mode 100644 index 0000000..6e1aa52 --- /dev/null +++ b/lib/presentation/components/toast/flushbar.dart @@ -0,0 +1,43 @@ +import 'package:another_flushbar/flushbar.dart'; +import 'package:flutter/material.dart'; + +import '../../../common/theme/theme.dart'; + +class AppFlushbar { + static void showSuccess(BuildContext context, String message) { + Flushbar( + messageText: Text( + message, + style: AppStyle.lg.copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + icon: const Icon(Icons.check_circle, color: Colors.white), + duration: const Duration(seconds: 2), + flushbarPosition: FlushbarPosition.BOTTOM, + backgroundColor: AppColor.secondary, + borderRadius: BorderRadius.circular(12), + margin: const EdgeInsets.all(12), + ).show(context); + } + + static void showError(BuildContext context, String message) { + Flushbar( + messageText: Text( + message, + style: AppStyle.lg.copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + icon: const Icon(Icons.error, color: Colors.white), + duration: const Duration(seconds: 3), + flushbarPosition: FlushbarPosition.BOTTOM, + backgroundColor: AppColor.error, + borderRadius: BorderRadius.circular(12), + margin: const EdgeInsets.all(12), + ).show(context); + } +} diff --git a/pubspec.lock b/pubspec.lock index ce8fdee..2d97622 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.7.1" + another_flushbar: + dependency: "direct main" + description: + name: another_flushbar + sha256: "19bf9520230ec40b300aaf9dd2a8fefcb277b25ecd1c4838f530566965befc2a" + url: "https://pub.dev" + source: hosted + version: "1.12.30" archive: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e05cdc1..a257839 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,6 +31,7 @@ dependencies: line_icons: ^2.0.3 flutter_spinkit: ^5.2.2 fl_chart: ^1.0.0 + another_flushbar: ^1.12.30 dev_dependencies: flutter_test: