added cache for types

This commit is contained in:
Patrick Alvin Alcala 2025-03-20 15:05:21 +08:00
parent bcf9823ffb
commit 5c4c8ceca9
8 changed files with 109 additions and 9 deletions

View file

@ -7,6 +7,7 @@ import 'package:pharmacy_mobile/blocs/caches/categorylist/functions/cache_setcat
import 'package:pharmacy_mobile/blocs/caches/genericlist/functions/cache_setgenericlist.dart';
import 'package:pharmacy_mobile/tables/ref_categories.dart';
import 'package:pharmacy_mobile/tables/ref_generic_names.dart';
import 'package:pharmacy_mobile/tables/ref_types.dart';
import 'package:pharmacy_mobile/widgets/buttonwithprogress_widget.dart';
import 'package:pharmacy_mobile/widgets/menu_widget.dart';
import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
@ -26,6 +27,7 @@ class _MainPageState extends State<MainPage> {
final _authService = AuthService();
final _refCategories = RefCategories();
final _refGenericNames = RefGenericNames();
final _refTypes = RefTypes();
late bool _isLoading = false;
@ -95,9 +97,23 @@ class _MainPageState extends State<MainPage> {
}
}
Future<void> _getTypeListCache() async {
final typeList = await _refTypes.getList();
if (typeList.isNotEmpty) {
// ignore: use_build_context_synchronously
final setCache = await cacheSetGenericList(context, typeList);
if (!setCache) {
// ignore: use_build_context_synchronously
showNotification(context, 'Caching failed', false);
}
}
}
void autoRun() async {
await _getCategoryListCache();
await _getGenericListCache();
await _getTypeListCache();
}
@override