1

can any one tell me why is there an error. im a beginner in flutter. can any one help.

this is the code, the error is on the onpressed fucntion.

Expanded(
                child: TextButton(
                  onPressed: () {},
                  child: Padding(
                    padding: EdgeInsets.all(16.0),
                    child: Image(
                      image: AssetImage('images/dice1.png'),
                    )
                  ),
    
                ),
    
              ),

error:

error: Invalid constant value. (invalid_constant at line 3)
error: The values in a const list literal must be constants. (non_constant_list_element at line 3)
chogyal
  • 13
  • 6

1 Answers1

3

Don't use the const keyword if you are not using fixed values. Flutter uses the const keyword as an indicator for a widget to never rebuild as it will get evaluated at compile time and only once.

Jignesh Patel
  • 223
  • 1
  • 4