0

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?

Wiktor_B
  • 395
  • 1
  • 4
  • 8

1 Answers1

3

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.