When I build after changing Xfile to file, it says null check operator user on a null value, but I don’t know what the problem is
The code is too long, so I’ll just write the gist
please help me……
XFile? _imageFile;
File file = File(_imageFile!.path);
>Solution :
- Are you picking any file in XFile or just declaring it?
Then of course you’re going to get null value
Otherwise,
Add a check when you’ve picked a file from user
XFile? imageFile;
imageFile = //Your File Picking logic
if(imageFile != null) {
File _file = File(imageFile!.path);
}
Else you can also try reading the bytes if in any case your file path is inaccessible and create a new file object
imageFile!.readAsBytes();