I was trying to use a ListView.builder to display a list of Images dynamically as they are saved into an array of type File,
Here is my code :
List<File> viewImg = [].toList();
_imgFromGallery() async {
File image = await ImagePicker.pickImage(
source: ImageSource.gallery, imageQuality: 50);
setState(() {
_image = image;
viewImg.add(image);
});
}
ListView.builder(
itemCount: viewImg.length,
itemBuilder: (BuildContext context, int index) {
return new SingleChildScrollView(
physics: ScrollPhysics(),
child: Column(children: [
Container(
margin:EdgeInsets.only(top30),
width: size.width * .8,
height: 149,
decoration: BoxDecoration(
image: DecorationImage(
image:FileImage(viewImg[index]),
)),
),
Every time I run it I get the error:
type 'List<dynamic>' is not a subtype of type 'List<File>'.
Please help me out and thanks in advance.