I wish to display image taken from the Camera. My imports are -
import 'dart:html';
import 'dart:io';
import 'package:file/file.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
The code block with the issue
class _CollectdataState extends State<Collectdata> {
XFile imageFile;
_getFromCamera() async {
XFile? pickedFile = await ImagePicker().pickImage(
source: ImageSource.camera,
maxWidth: 1800,
maxHeight: 1800,
);
if (pickedFile != null) {
File imageFile = File(pickedFile.path);
}
}
The error here was
1.File needs 2 parameters- I am unsure on what the second parameter is.
Then I changed something around idr what exactly but the imports if I remember correctly and this was the new error-
- File is not a function
I need to change it to a File inorder to upload on Firebase and show the picture using image.file() Any help is highly appreciated!
CodePudding user response:
Please remove
import 'dart:html';
If this package isn't used. Both html and dart:io provide File. The error that you mentioned was for File from html.