Is there any GraphDeveloper?...I am working on a project and got stuck on a problem that when i user dart:io
package I open picker = ImagePicker();
images get displayed on web with uint8List
inside the ListView.builder
. But when i try to upload them to server by using GraphQL_API
. I get an error that Error: Unsupported Operation: _namespace
. I tried some #stackOverFlow searches and found a package universal_io
. but when I used this package this didn't even picked any image or file nor gave me some error telling that if its possible or not. When I searched about the above error i got a point that dart:io
sometimes does not support some of features on Flutter_web
.
here I am attaching my Code.
This is my imagePickerCode
final picker = ImagePicker();
List<File> images = [];
List<int> imageFiles = [];
List<Uint8List> webImage =[];
List<Uint8List> uint8Files =[];
List<XFile>? xFiless = [];
void _imgFromGallery() async {
List<XFile>? files = await picker.pickMultiImage(
imageQuality: 50,
);
print("pickedFile: ${files}");
if (files != null) {
for (var element in files) {
setState(() {
xFiless?.add(element);
print("X_instances: $xFiless");
images.add(File(element.name));
uint8Files = webImage;
print("FilePath: ${File(element.name)}");
});
webImage.add(await element.readAsBytes());
}
}
}
String uint8ListTob64(Uint8List uint8list) {
String base64String = base64Encode(uint8list);
String header = "data:image/jpeg;base64,";
// print("${header} ::${base64String}");
return header + base64String;
}
This is my UploadImageMethod()
Future<void> uploadImage(File image) async {
int responseId = await UploadImages.multipartApi(File(image.toString()));
if(responseId != 0){
imageFiles.add(responseId);
print("ImageFile List= ${imageFiles.toString()}");
}
}
This is my API CAll
static Future<int> multipartApi(File file)async {
print("image_file_path=${file.path}");
var byteData = file.readAsBytesSync();
print("byteData: $byteData");
var multipartFile = MultipartFile.fromBytes(
"",
byteData,
filename: "${DateTime.now().second}.jpeg",
contentType: MediaType("image", "jpeg"),
);
here i am making the actual task
Future<void> addTransaction() async {
FocusScope.of(context).unfocus();
UIHelper.apiCallingAlert(context);
List imageIds = [];
for (var element in images) {
String elementPath = element.path;
print("element: ${elementPath}");
await uploadImage(element);
}
after all doing this stuff i get some Blob
errors.