update
This commit is contained in:
parent
5164d55905
commit
6f54a6f9fc
65 changed files with 313 additions and 137 deletions
|
|
@ -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