add cache for medicines
This commit is contained in:
parent
518415aa4e
commit
92df0af895
12 changed files with 110 additions and 14 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
|
|
@ -6,10 +8,12 @@ import 'package:pharmacy_mobile/auth/auth_service.dart';
|
|||
import 'package:pharmacy_mobile/blocs/caches/categorylist/functions/cache_setcategorylist.dart';
|
||||
import 'package:pharmacy_mobile/blocs/caches/genericlist/functions/cache_setgenericlist.dart';
|
||||
import 'package:pharmacy_mobile/blocs/caches/manufacturerlist/functions/cache_setmanufacturerlist.dart';
|
||||
import 'package:pharmacy_mobile/blocs/caches/medicinelist/functions/cache_setmedicinelist.dart';
|
||||
import 'package:pharmacy_mobile/blocs/caches/typelist/functions/cache_settypelist.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_categories.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_generic_names.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_manufacturers.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_medicines.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';
|
||||
|
|
@ -32,6 +36,7 @@ class _MainPageState extends State<MainPage> {
|
|||
final _refGenericNames = RefGenericNames();
|
||||
final _refTypes = RefTypes();
|
||||
final _refManufacturers = RefManufacturers();
|
||||
final _refMedicines = RefMedicines();
|
||||
|
||||
late bool _isLoading = false;
|
||||
|
||||
|
|
@ -115,11 +120,22 @@ class _MainPageState extends State<MainPage> {
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
await _getCategoryListCache();
|
||||
await _getGenericListCache();
|
||||
await _getTypeListCache();
|
||||
await _getManufacturerListCache();
|
||||
await _getMedicineListCache();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue