fixed cache
This commit is contained in:
parent
d3f708ae5e
commit
64516a7df2
7 changed files with 93 additions and 21 deletions
|
|
@ -70,6 +70,7 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
late bool imageUploaded = false;
|
||||
late String imageUrl = '';
|
||||
late bool uploaded = false;
|
||||
late String imageUUID = '';
|
||||
|
||||
Future<void> _getGenerics() async {
|
||||
_genericNameList = await _refGenericNames.getList();
|
||||
|
|
@ -174,12 +175,6 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
final distributors = await _getDistributorsCache();
|
||||
final suppliers = await _getSuppliersCache();
|
||||
|
||||
print('generics: $generics');
|
||||
print('types: $types');
|
||||
print('manufacturers: $manufacturers');
|
||||
print('distributors: $distributors');
|
||||
print('suppliers: $suppliers');
|
||||
|
||||
if (!generics || !types || !manufacturers || !distributors || !suppliers) {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
await _getGenerics();
|
||||
|
|
@ -268,6 +263,7 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
try {
|
||||
// final String encrpytedBarcode = await encrypt(_barcodeController.text);
|
||||
final String encrpytedBarcode = _barcodeController.text;
|
||||
uuid = Uuid().v4();
|
||||
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
final medName = _nameController.text;
|
||||
|
|
@ -277,8 +273,12 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
final medDistributorUUID = await _refDistributors.getUUID(_selectedDistributor);
|
||||
final medSupplierUUID = await _refSuppliers.getUUID(_selectedSupplier);
|
||||
|
||||
if (imageUUID.isEmpty) {
|
||||
imageUUID = '73105ee3-74bd-40ea-9434-f8176a980b43';
|
||||
}
|
||||
|
||||
final posted = await _refMedicines.postMedicine(uuid, medName, medManufacturerUUID, medGenericUUID, medTypeUUID,
|
||||
encrpytedBarcode, medDistributorUUID, medSupplierUUID);
|
||||
encrpytedBarcode, medDistributorUUID, medSupplierUUID, imageUUID);
|
||||
|
||||
if (posted) {
|
||||
if (mounted) {
|
||||
|
|
@ -315,7 +315,7 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
final imageBytes = await image!.readAsBytes();
|
||||
final webpImage = await _webpConvert(imageBytes);
|
||||
|
||||
uuid = imageName;
|
||||
imageUUID = imageName;
|
||||
|
||||
if (mounted) {
|
||||
uploaded = await _storage.uploadImage(context, storageName, webpImage, '$imageName.webp');
|
||||
|
|
@ -466,12 +466,12 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
// const Center(child: CircularProgressIndicator(color: Colors.white))
|
||||
// else
|
||||
// ButtonWidget(text: 'Save Medicine', onPressed: _saveMedicine)
|
||||
if (uploaded)
|
||||
ButtonWithProgressWidget(
|
||||
trigger: _isLoading,
|
||||
progressText: 'Adding Medicine',
|
||||
buttonText: 'Save',
|
||||
onPressed: _saveMedicine)
|
||||
// if (uploaded)
|
||||
ButtonWithProgressWidget(
|
||||
trigger: _isLoading,
|
||||
progressText: 'Adding Medicine',
|
||||
buttonText: 'Save',
|
||||
onPressed: _saveMedicine)
|
||||
])
|
||||
])))
|
||||
]))));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue