update
This commit is contained in:
parent
5164d55905
commit
6f54a6f9fc
65 changed files with 313 additions and 137 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class RefMedicines {
|
||||
final SupabaseClient _supabase = Supabase.instance.client;
|
||||
|
|
@ -17,14 +16,20 @@ class RefMedicines {
|
|||
return data.toList();
|
||||
}
|
||||
|
||||
Future<List> getListWithUUID() async {
|
||||
final data = await _supabase
|
||||
.from('ref_medicines')
|
||||
.select('ref_medicines_uuid, medicine_name')
|
||||
.order('medicine_name', ascending: true);
|
||||
return data.toList();
|
||||
}
|
||||
|
||||
Future<String> getUUID(String name) async {
|
||||
final data = await _supabase.from('ref_medicines').select('ref_medicines_uuid').eq('medicine_name', name);
|
||||
return data.first['ref_medicines_uuid'];
|
||||
}
|
||||
|
||||
Future<void> postMedicine(String uuid, String name, String muuid, String guuid, String tuuid) async {
|
||||
// final uuid = Uuid().v4();
|
||||
|
||||
final medicine = {
|
||||
'ref_medicines_uuid': uuid,
|
||||
'medicine_name': name,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
class Storage {
|
||||
|
|
@ -39,7 +42,7 @@ class Storage {
|
|||
}
|
||||
}
|
||||
|
||||
Future<String> uploadImage(String storage, XFile image, String name) async {
|
||||
Future<String> uploadImage(BuildContext context, String storage, XFile image, String name) async {
|
||||
try {
|
||||
final imageBytes = await image.readAsBytes();
|
||||
final imagePath = name;
|
||||
|
|
@ -48,8 +51,19 @@ class Storage {
|
|||
final imageUrl = _supabase.storage.from(storage).getPublicUrl(imagePath);
|
||||
return imageUrl;
|
||||
} catch (e) {
|
||||
log('Error uploading image: $e');
|
||||
// ignore: use_build_context_synchronously
|
||||
showNotification(context, 'Error uploading image: $e', false);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Uint8List> downloadImage(String storage, String name) async {
|
||||
final Uint8List file = await _supabase.storage.from(storage).download(name);
|
||||
return file;
|
||||
}
|
||||
|
||||
Future<String> getPublicURL(String storage, String name) async {
|
||||
final String file = _supabase.storage.from(storage).getPublicUrl(name);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue