added cache for categories
This commit is contained in:
parent
753c730588
commit
1aa7410e2e
14 changed files with 195 additions and 63 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:gap/gap.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
import 'package:pharmacy_mobile/blocs/caches/categorylist/functions/cache_getcategorylist.dart';
|
||||
import 'package:pharmacy_mobile/functions/checkexisting_function.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_categories.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_generic_names.dart';
|
||||
|
|
@ -28,7 +29,8 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
final _nameController = TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
bool _isLoading = false;
|
||||
late bool _isLoading = false;
|
||||
late final List _categoryListCache = [];
|
||||
|
||||
late List _categoryList = [];
|
||||
late String _selectedCategory = '';
|
||||
|
|
@ -52,22 +54,34 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
}
|
||||
}
|
||||
|
||||
void autoRun() async {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
_getList();
|
||||
} else {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: No Internet Connection', false);
|
||||
Future<void> _getCategory() async {
|
||||
final categoryListCache = await cacheGetCategoryList(context);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
context.push('/main');
|
||||
}
|
||||
});
|
||||
if (categoryListCache.isNotEmpty) {
|
||||
setState(() {
|
||||
_categoryList = categoryListCache;
|
||||
});
|
||||
} else {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
_getList();
|
||||
} else {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: No Internet Connection', false);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
context.push('/main');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void autoRun() async {
|
||||
_getCategory();
|
||||
}
|
||||
|
||||
void _updateCategory(dynamic category) {
|
||||
_selectedCategory = category;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue