what went wrong? even if i replace the XFile into File, same error comes at this putFile.
Asked
Active
Viewed 33 times
0
-
what exactly is the error message ? – Romario Rio Jan 27 '23 at 03:50
-
The argument type 'String' can't be assigned to the parameter type 'List – palani Jan 27 '23 at 09:27
-
2 positional argument(s) expected, but 1 found. – palani Jan 27 '23 at 09:27
2 Answers
0
try this convert that xfile to file
uploadImages(XFile? pathsw) async {
final paths = path.basename(pathsw!.path);
final pathStorage =
"${NAMEFOLDER}/${PATHNAME}/$paths";
/// Start looking from here then so on
final file = File(pathsw.path);
final reference = FirestoreService.storage.ref().child(pathStorage);
final task = reference.putFile(file);
final snap = await task.whenComplete(() {});
final url = await snap.ref.getDownloadURL();
return url;
}

Arbiter Chil
- 1,061
- 1
- 6
- 9
0
If you see, .putFile()
takes in a element of File
type. And you're accepting of type XFile
. To convert:
File uploadImage = File(image!.path)
now the best way to upload would be to use .putFile()
or .putData()
Your .putFile()
implementation looks great, if you want to use .putData()
, find the following code:
await reference.putData(uploadImage.readAsBytesSync())

Delwinn
- 891
- 4
- 19