'Button List Select
I have a list of the button in my flutter app like the picture :enter image description here
and I need to select the container who I'm click on it for example, change the container color
Solution 1:[1]
TBH I'm not sure what your asking exactly, but this may or may not help you:
GestureDetector
This will let you respond to clicks on whatever it surrounds, so for example
return
GestureDetector(
onTap: (){
//Do something here to respond to a tap on the child Container()
},
child: Container(...) /// Your box
Now you can do something with it.
Hope this is what you were asking about
Solution 2:[2]
You can also use InkWell in this following way,
First you have to declare Color in your instances and after that you can use it in your onPress() widget.
Color _colorContainer = Colors.blue;
Now you can use it in your widget as follow:
Ink(
child: InkWell(
child: Container(
width: 200,
height: 200,
color: _colorContainer ,
),
onTap: () {
setState(() {
_colorContainer = _colorContainer == Colors.red ?
Colors.blue :
Colors.red;
});
},
)),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mark |
| Solution 2 | Manishyadav |
