i'm learning flutter ,can anyone help me how i can pass ImageFileList to image.file widget or if someone has any other suggestion please comemnt it really relp me.Using gridVeiw builder to preview images
final ImagePicker imagePicker = ImagePicker();
List<XFile> imageFileList = [];
void selectedImage() async {
final List<XFile> selectedImage = await imagePicker.pickMultiImage();
if (selectedImage.isNotEmpty) {
imageFileList.addAll(selectedImage);
}
}
Image.file()//here
CodePudding user response:
you need to use index and this converter:
Image.file(File(imageFileList[1].path))
you can use it ListView
like this:
ListView.builder(
itemBuilder: (context, index) {
return Image.file(File(imageFileList[index].path));
},
itemCount: imageFileList.length,
)
also remember import 'dart:io'
not import 'dart:html'
;