Convert List<XFile> to File in Dart / Flutter

I pick a picture using this library image_picker: 0.8.4+4. Then the image saved into List..

After that i want to show the image in next page and make it ready to edit using this library image_painter: 0.4.4+1.

ImagePainter.file(
        // Need file,
        key: _imageKey,
        scalable: true,
        initialStrokeWidth: 2,
        initialColor: Colors.green,
        initialPaintMode: PaintMode.line,
      ),

Actually i just need how to convert List<XFile> to File


Solution 1:

One way to do it:

XFile has a property called path so the you can:

XFile xfile = ...;

File file = File(xfile.path);

If you have a list, you can use map or other way you prefer to create File using the path of a XFile.