added refresh of medicine cache

This commit is contained in:
Patrick Alvin Alcala 2025-07-10 14:52:00 +08:00
parent a2117b926f
commit d130aef56c

View file

@ -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<AddMedicinePage> {
}
}
Future<void> _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<AddMedicinePage> {
encrpytedBarcode, medDistributorUUID, medSupplierUUID, imageUUID);
if (posted) {
_getMedicineListCache();
if (mounted) {
showNotification(context, 'Medicine Added Successfully', true);
setState(() => _isLoading = false);