how to asses widget which is in the list?
I want to assess widgets in the form of list in navigator.push but a error is popping up "Error: The getter 'index' isn't defined for the class 'Textwidget'." so what can i do to solve this
class Textwidget extends StatelessWidget {
late String text;
Textwidget(this.text);
List<Widget> gridMembersPath = [
wewre(),
];
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context){
return (gridMembersPath[index]);
}));
},
child: Container(
margin: EdgeInsets.only(left: MediaQuery.of(context).size.width * 0.1),
child: Text(
text,
style: TextStyle(fontSize: 20,color: Colors.grey),
),
),
);
}
}
Solution 1:
Check out for the arguments property in Navigator class. https://docs.flutter.dev/cookbook/navigation/navigate-with-arguments do upvote if helpful