I came across this question : How to identify which button is clicked in flutter
But Is there any better way to detect which button is tapped? Ex. I created 100 button via for loop then how to know? In iOS we are using tag property so If there is this kind of option then it will really handy to detect.
EDITED:
Below are my code
List<Widget> pageCurrentPageIndicator(int currentIndex, int totoalCount) {
List<Widget> tempWidget = new List<Widget>();
for (var i = 0; i < totoalCount; i++) {
Container container = Container(
width: 47.0,
height: 30.0,
child: FlatButton(
child: Image.asset(
(i == currentIndex
? 'lib/assets/radioBtnActive.png'
: 'lib/assets/radioBtn.png'),
fit: BoxFit.contain), onPressed: () {
whichButtonistaped(i);
},
)
);
tempWidget.add(container);
}
return tempWidget;
}
void whichButtonistaped(int btnTag){
print(btnTag);
setState(() {
currentBannerIndex = btnTag;
});
}