Error: Not a constant expression. (Flutter) Error: Not a constant expression. (Flutter) dart dart

Error: Not a constant expression. (Flutter)


Here const AssetImage(snapshot.data[index]) you are using a const constructor. The compiler is expecting a compile time constant and is complaining because the arguments you are passing in are not constant but depend on the runtime value of snapshot.data.

If you simply remove the const keyword it should compile without errors.