Flutter upload image to Firebase Storage and get download URL with Image Picker quick code

preview_player
Показать описание
Code:
------------------------------------------------------------------------------------------------------
//image_picker: ^0.6.7+14
//firebase_storage: ^5.0.1

import 'dart:io';

void demo() async {
var pickedImage = await ImagePicker().getImage(
maxWidth: 1920,
maxHeight: 1200, //specify size and quality
imageQuality: 80); //so image_picker will resize for you

var anotherPickedImage = await ImagePicker().getImage(
maxWidth: 1920,
maxHeight: 1200,
imageQuality: 80);

//upload and get download url

// To use the image within your widgets:
}
-----------------------------------------------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Thank you so much. It's really helpful🥰

kaushalyaroshan
Автор

Hey, im getting this error: Exception has occurred.
FirebaseException No object exists at the desired reference.) and how i can create a folder on storage, and there save the images? im trying this:

Future<void> uploadPic(File foto) async {
final Reference postImageRef =
Images');
var timeKey = DateTime.now();
await + async {
await {
posts.imageUrl = value;
});
});
return posts.imageUrl;
}

David-fkqj