From d130aef56c6a153b2f30523f75346cf7c13daad2 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Thu, 10 Jul 2025 14:52:00 +0800 Subject: [PATCH] added refresh of medicine cache --- lib/pages/add_medicine_page.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/pages/add_medicine_page.dart b/lib/pages/add_medicine_page.dart index feb3af1..84bfdd1 100644 --- a/lib/pages/add_medicine_page.dart +++ b/lib/pages/add_medicine_page.dart @@ -6,6 +6,7 @@ import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:pharmacy_mobile/blocs/caches/distributorlist/functions/cache_getdistributorlist.dart'; import 'package:pharmacy_mobile/blocs/caches/genericlist/functions/cache_getgenericlist.dart'; import 'package:pharmacy_mobile/blocs/caches/manufacturerlist/functions/cache_getmanufacturerlist.dart'; +import 'package:pharmacy_mobile/blocs/caches/medicinelist/functions/cache_setmedicinelist.dart'; import 'package:pharmacy_mobile/blocs/caches/supplierlist/functions/cache_getsupplierlist.dart'; import 'package:pharmacy_mobile/blocs/caches/typelist/functions/cache_gettypelist.dart'; import 'package:pharmacy_mobile/functions/barcode_scan_function.dart'; @@ -168,6 +169,16 @@ class _AddMedicinePageState extends State { } } + Future _getMedicineListCache() async { + final medicineList = await _refMedicines.getList(); + + if (medicineList.isNotEmpty) { + // ignore: use_build_context_synchronously + final setCache = await cacheSetMedicineList(context, medicineList); + if (!setCache) {} + } + } + void autoRun() async { final generics = await _getGenericsCache(); final types = await _getTypesCache(); @@ -281,6 +292,8 @@ class _AddMedicinePageState extends State { encrpytedBarcode, medDistributorUUID, medSupplierUUID, imageUUID); if (posted) { + _getMedicineListCache(); + if (mounted) { showNotification(context, 'Medicine Added Successfully', true); setState(() => _isLoading = false);