fixed cache
This commit is contained in:
parent
d3f708ae5e
commit
64516a7df2
7 changed files with 93 additions and 21 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
import 'package:pharmacy_mobile/blocs/caches/categorylist/functions/cache_setcategorylist.dart';
|
||||
import 'package:pharmacy_mobile/functions/checkexisting_function.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_categories.dart';
|
||||
import 'package:pharmacy_mobile/widgets/buttonwithprogress_widget.dart';
|
||||
|
|
@ -23,8 +24,19 @@ class _AddCategoryPageState extends State<AddCategoryPage> {
|
|||
final _formKey = GlobalKey<FormState>();
|
||||
final _categoryController = TextEditingController();
|
||||
final _refCategories = RefCategories();
|
||||
|
||||
bool _isLoading = false;
|
||||
|
||||
Future<void> _getCategoryListCache() async {
|
||||
final categoryList = await _refCategories.getList();
|
||||
|
||||
if (categoryList.isNotEmpty) {
|
||||
// ignore: use_build_context_synchronously
|
||||
final setCache = await cacheSetCategoryList(context, categoryList);
|
||||
if (!setCache) {}
|
||||
}
|
||||
}
|
||||
|
||||
void _saveCategory() async {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
|
|
@ -40,6 +52,7 @@ class _AddCategoryPageState extends State<AddCategoryPage> {
|
|||
final post = await _refCategories.postCategory(_categoryController.text.toUpperCase());
|
||||
|
||||
if (post && mounted) {
|
||||
_getCategoryListCache();
|
||||
showNotification(context, 'Category saved', true);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue