Can I change margin in AnimatedContainer?

530 Views Asked by At

I'm building a list using ListWheelScrollView and I would like to change margin value of container below the centre one. I'm also using AnimatedContainer.

 margin: const EdgeInsets.only( left: x == selected ? 13 : 10),

This code gives me error : Error: Not a constant expression. left: x == selected ? 13 : 10), Is there a way to avoid it?

1

There are 1 best solutions below

1
AudioBubble On BEST ANSWER

Yes there is a very simple way to avoid this problem. You should remove the const keyword. The const keyword in Dart indicates that a value will not be changed after compiling. This will be violated when x == selected returns true for example.