so i tried this to get an image and upload it:
var file;
html.InputElement uploadInput = html.FileUploadInputElement()
..accept = "image/*";
uploadInput.click();
uploadInput.onChange.listen((event) {
file = uploadInput.files.first;
final reader = html.FileReader();
reader.readAsDataUrl(file);
reader.onLoadEnd.listen((event) async {
print("done");
StorageReference storageReference = FirebaseStorage.instance
.ref()
.child('${widget.uid}/${DateTime.now()}');
StorageUploadTask uploadTask = storageReference.putData(file);
await uploadTask.onComplete;
print('File Uploaded');
print(storageReference.path);
storageReference.getDownloadURL().then((fileURL) {
setState(() {
_uploadedFileURL = fileURL;
});
});
});
});
as shown in a tutorial,however the guy use .put() and not putData() but it's now deprecated, so when using .put() i get:
Expected a value of type 'File', but got one of type 'File$'
and with .putData() i get:
Expected a value of type 'Uint8List', but got one of type 'File$'
Any ideas how i could convert File$ or directly import a File or Uint8List from the user from Flutter Web? Thanks