postImageOnFirebase function

Future<String> postImageOnFirebase(
  1. dynamic collection,
  2. File file
)

Implementation

Future<String> postImageOnFirebase(collection, File file) async {
  Reference ref = FirebaseStorage.instance
      .ref()
      .child(collection + "/${DateTime.now().microsecondsSinceEpoch}");
  UploadTask uploadTask = ref.putFile(file);

  try {
    await uploadTask;
    String? profile = await ref.getDownloadURL();
    return profile;
  } catch (e) {
    return handleFirebaseStorageError(e);
  }
}