Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Exception caught by widgets library null check to xfile to file

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……

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

XFile? _imageFile; 
File file = File(_imageFile!.path); 

>Solution :

  1. 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();
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading