A Flutter package for easy file uploads to Supabase storage with progress tracking.
- Single and multiple file uploads
- Upload progress tracking
- Pause, resume, and cancel uploads
- Direct access to upload controller for more granular control
Add this package to your pubspec.yaml
:
dependencies:
supabase_progress_uploads: ^1.0.0
final supabase = Supabase.instance.client;
final uploadService = SupabaseUploadService(supabase, 'your-bucket-name');
String? url = await uploadService.uploadFile(
file,
onUploadProgress: (progress) {
print('Upload progress: ${progress}%');
},
);
print('Uploaded file URL: $url');
List<String?> urls = await uploadService.uploadMultipleFiles(
files,
onUploadProgress: (progress) {
print('Total upload progress: ${progress}%');
},
);
print('Uploaded files URLs: $urls');
For more granular control over the upload process:
final controller = SupabaseUploadController(supabase, 'your_bucket_name');
int fileId = await controller.addFile(file);
controller.startUpload(
fileId,
onUploadProgress: (progress) {
print('Upload progress: ${progress}%');
},
);
String? url = await controller.getUploadedUrl(fileId);
print('Uploaded file URL: $url');
controller.pauseUpload(fileId);
controller.resumeUpload(fileId);
await controller.cancelUpload(fileId);
Make sure to properly initialize Supabase in your app before using this package. For more detailed examples, check the example
folder in the package repository.
Remember to dispose of the upload service when you're done:
@override
void dispose() {
uploadService.dispose();
super.dispose();
}
For issues, feature requests, or contributions, please visit the GitHub repository.