You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have made a list from a string and then made button from that list. Now, I want that when the button is pressed it will change it's color. Currently I have done the following but it only change the button color for a moment. Can it be permanently changed?
List<Widget> _buildButtonsWithNames() {
for (int i = 0; i < wordlist.length; i++) {
buttonsList.add(
new ElevatedButton(
onPressed: () => {
},
child: Text(wordlist[i]),
style: ButtonStyle(
overlayColor: getColor(Colors.white, Colors.teal),
backgroundColor: getColor(Colors.blue, Colors.red)),
),
);
}
return buttonsList;
}
MaterialStateProperty<Color> getColor(Color color, Color colorPressed) {
final getColor = (Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return colorPressed;
} else {
return color;
}
};
return MaterialStateProperty.resolveWith(getColor);
}
The text was updated successfully, but these errors were encountered:
I have made a list from a string and then made button from that list. Now, I want that when the button is pressed it will change it's color. Currently I have done the following but it only change the button color for a moment. Can it be permanently changed?
The text was updated successfully, but these errors were encountered: