Get selected image path through Asset in flutter?
FlutterAbsolutePath is not supported to null safety
I used button click event to get the image Path from Asset
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () async {
final key = DateTime.now().toString();
File file = await getImageFileFromAssets(images[1]);
for(int i=0;i<images.length;i++)
{
print('# file path is ${file.path} #');
}
},
),
The method which is converting Asset to the image path
Future<File> getImageFileFromAssets(Asset asset) async {
final byteData = await asset.getByteData();
final tempFile =
File("${(await getTemporaryDirectory()).path}/${asset.name}");
final file = await tempFile.writeAsBytes(
byteData.buffer
.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes),);
return file;
}
Prasath
தோல்வி நிலையென நினைத்தால் மனிதன் வாழ்வை நினைக்கலாமா > Parunthaguthu Oor Kuruvi, Adangathathu En Piravi, Adanga Pala Madanga > Varum, Thaduththa Adthu Udachchi Varuven, Ippo Vanthu Mothu Da, Kitta > Vanthu Paru Da, Kattaruntha Kala, Nenju Mela Era Pothu Da, Thimiru Da > Thimira Thimira, Nimiru Da Nilama Nilama, Unaru Da Payanam Payanam, > Thodarum Da, Tha Ippo Vanthu Mothu Da, Kitta Vanthu Paru Da Paru Da, Porus ---- My Rule. Don't ask me, What is the Update or What is the Progress, However, I will be give you on correct time
Updated on December 31, 2022Comments
-
Prasath over 1 year
I used multi_image_picker: to select images from the internal storage. This library returns
List
ofAsset
, but I want as an image path, I usedFlutterAbsolutePath
var path = await FlutterAbsolutePath.getAbsolutePath(resultList[i].identifier);
but this is not supported to null safety, How can I get an image path using the similar library?