I am follow the passing value to next page so i can get the data but when i use listview for show the image the app alert 'Invalid value: Not in inclusive range 0..1: -1'
where should i fix code?
Container(
margin: const EdgeInsets.symmetric(vertical: 20.0),
height: 130.0,
child: ListView.builder(
itemCount: keepImage.length,
scrollDirection: Axis.horizontal,
shrinkWrap: true,
// itemCount: 1,
itemBuilder: (context, index) {
return InkWell(
child: Padding(
padding: EdgeInsets.only(
top: 8.0,
bottom: 8.0,
left: 8.0,
right: 8.0),
child: Container(
height: 140,
width: 140,
child: Container(
child: ClipRRect(
borderRadius:
BorderRadius.circular(8),
child: AspectRatio(
aspectRatio: 1.2,
child: Container(
width: double.infinity,
height: 400,
decoration: BoxDecoration(
image: DecorationImage(
image: FileImage(
keepImage[index - 1]),
fit: BoxFit.cover)),
),
)),
)),
));
}),
),
CodePudding user response:
In your code FileImage(keepImage[index - 1])
. You are subtracting index with 1 which will result in -1. But accepted value in 0 or a value greater than 0. Change it to FileImage(keepImage[index])
. Then it should work as expected.