I searched alot on net for answer.
I wrote iteration on list of letters and put inside cards on screen using "map"
class
In the code you can see that i made a row and using "map" printed aall the userBoard on cards to the screen.
I want to add some logics inside so i need to gett the id of the elemnt (for taping event).
Theres a way that i can do taht?
Actually i want to get a specific index of element over userBoard
code:
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Row(
children: userBoard
.map((element) => Stack(children: <Widget>[
Align(
alignment: Alignment(0, -0.6),
child: GestureDetector(
onTap: (() {
setState(() {
// print("element=${element.toString()}");
// print("element=${userBoard[element]}");
});
}),
child: SizedBox(
width: 40,
height: 60,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
child: Center(
child: Text(element,
style: TextStyle(fontSize: 30)),
)),
),
),
)
]))
.toList(),
)
],
),
}
Picture - each card is "element" of the map. I want to get the indexes for the function onTap.
Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…