Is there a way to use an asset image as a File. I need a File so it can be used for testing it over the internet using http. I've tried some answers from Stackoverflow.com (How to load images with image.file) but get an error 'Cannot open file, (OS Error: No such file or directory, errno = 2)'. The attached code line also gives an error.
File f = File('images/myImage.jpg');
RaisedButton(
onPressed: ()=> showDialog(
context: context,
builder: (_) => Container(child: Image.file(f),)),
child: Text('Show Image'),)
Using Image.memory widget(works)
Future<Null> myGetByte() async {
_byteData = await rootBundle.load('images/myImage.jpg');
}
/// called inside build function
Future<File> fileByte = myGetByte();
/// Show Image
Container(child: fileByte != null
? Image.memory(_byteData.buffer.asUint8List(_byteData.offsetInBytes, _
byteData.lengthInBytes))
: Text('No Image File'))),