fixed cache

This commit is contained in:
Patrick Alvin Alcala 2025-07-09 17:09:55 +08:00
parent d3f708ae5e
commit 64516a7df2
7 changed files with 93 additions and 21 deletions

View file

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart';
import 'package:internet_connection_checker/internet_connection_checker.dart';
import 'package:pharmacy_mobile/blocs/caches/manufacturerlist/functions/cache_setmanufacturerlist.dart';
import 'package:pharmacy_mobile/functions/checkexisting_function.dart';
import 'package:pharmacy_mobile/tables/ref_manufacturers.dart';
import 'package:pharmacy_mobile/widgets/buttonwithprogress_widget.dart';
@ -27,6 +28,16 @@ class _AddManufacturerPageState extends State<AddManufacturerPage> {
late bool _isLoading = false;
Future<void> _getManufacturerListCache() async {
final manufacturerList = await _refManufacturers.getList();
if (manufacturerList.isNotEmpty) {
// ignore: use_build_context_synchronously
final setCache = await cacheSetManufacturerList(context, manufacturerList);
if (!setCache) {}
}
}
void _saveManufacturer() async {
setState(() => _isLoading = true);
@ -42,6 +53,7 @@ class _AddManufacturerPageState extends State<AddManufacturerPage> {
final post = await _refManufacturers.postManufacturer(_nameController.text, _addressController.text);
if (post && mounted) {
_getManufacturerListCache();
showNotification(context, 'Manufacturer added to list', true);
WidgetsBinding.instance.addPostFrameCallback((_) {