I am using list.generate using a list in flutter , doesn't know what is cause such problem.
my list have only two objects but error says 5 , what should i do now? `
List storyList = [
{
"name": "Novac",
"imageUrl": "https://randomuser.me/api/portraits/men/31.jpg",
"isOnline": true,
"hasStory": true,
},
{
"name": "Derick",
"imageUrl": "https://randomuser.me/api/portraits/men/81.jpg",
"isOnline": false,
"hasStory": false,
},];`
`
Row(
children: List.generate(storyList.length, (index) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: Column(
children: [
SizedBox(
width: 80,
height: 80,
child: Stack(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [
// Color(0xffcc306C),
Color.fromARGB(255, 255, 0, 225),
Color.fromARGB(255, 255, 48, 48),
Color.fromARGB(255, 255, 217, 67)
],
begin: Alignment.topRight,
end: Alignment.bottomLeft,
tileMode: TileMode.clamp,
),
// border: Border.all(
// // color: Color(0xffcc306C),
// width: 5)
),
child: Padding(
padding: EdgeInsets.all(3.0),
child: Container(
width: 75,
height: 75,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 4),
shape: BoxShape.circle,
image: DecorationImage(
image: NetworkImage(
storyList[index]
['imageUrl'],
),
fit: BoxFit.cover)),
),
)),
],
)),
SizedBox(
height: 5,
),
SizedBox(
width: 75,
child: Align(
child: Text(storyList[index]['name'],
overflow: TextOverflow.ellipsis,
style: GoogleFonts.roboto(
color: Colors.white,
fontSize: 12,
fontWeight: FontWeight.w600))))
],
));
}),
)
],
))
` EXCEPTION CAUGHT BY WIDGETS : The following RangeError was thrown building HomePage(dirty): RangeError (index): Invalid value: Not in inclusive range 0..1: 5
CodePudding user response:
Actually, I ran this code and it was built successfully with no error.
CodePudding user response:
I found , there was another widget that was causing the issue. thanking everyone for your help.