New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to get Image and File? #8
Comments
I had the same issue - here's how I overcame it (it was before @Ahmadre updated to pick File). Sorry - I haven't modified code so might be a little messy. Hopefully this may help. I'm hoping to re-integrate image_picker_web back in to clean the code up when I get some time. Note: import 'dart:html' as html; Button for Picker:
uploadImage()
convertFileToImage()
convertFileGetName()
Add User Button
uploadProfilePhoto()
|
Guys this was already answered: This has nothing to do with my package. In Image_Picker for native mobile it's the same: it's returning a File! The plus in this package is, that you got more options. But it seems that a lot of people gets confused why they got more options. Just have a look at the answer above and the related GIST. I'll close this issue, because it has nothing to do with the package. |
Thank you @jaxnz !.. This is great, I only needed the convertFileToImage method and works perfectly. They should add this method to the library. |
@clus90 It is in this library 😄 You just need MediaInfo for that. There's no need for such boilerplate reading again. import 'dart:html' as html;
import 'package:mime_type/mime_type.dart';
import 'package:path/path.dart' as Path;
import 'package:image_picker_web/image_picker_web.dart';
import 'package:flutter/material.dart';
html.File _cloudFile;
var _fileBytes;
Image _imageWidget;
Future<void> getMultipleImageInfos() async {
var mediaData = await ImagePickerWeb.getImageInfo;
String mimeType = mime(Path.basename(mediaData.fileName));
html.File mediaFile =
new html.File(mediaData.data, mediaData.fileName, {'type': mimeType});
if (mediaFile != null) {
setState(() {
_cloudFile = mediaFile;
_fileBytes = mediaData.data;
_imageWidget = Image.memory(mediaData.data);
});
}
} This will get you in one run every 3 types :) PS: I will add this to the readme for others out there. Thank you guys for asking this question 👍 |
Hi, I am using this library on a form, I would like to show the Image widget when the user selects the image (I've accomplished this), but when I submit the form I need the File info to send it to Firebase and it seems the only way to get both is requesting the image twice to the user, which is kind of annoying.
Thanks in advance,
The text was updated successfully, but these errors were encountered: