The argument type 'MaterialStateProperty<Color>?' can't be assigned to the parameter type 'Color'

Viewed 25

[Kindly help me with this The argument type 'MaterialStateProperty?' can't be assigned to the parameter type 'Color'.

answerColor: answerSelected
    ? answer['score']
        ? MaterialStateProperty.resolveWith<Color>(
          Colors.green; 
      )`enter code here`
        : MaterialStateProperty.resolveWith<Color>(
          Colors.red; 
      )
    : null,
1 Answers

your aswerColor is Color variable.Not MaterialStateProperty<Color>

answerColor : answerSelected
   ? answer['score']
        ? Colors.green
        : Colors.red
   : Color.what ever color you want.
   // because its non-null value, you cant set null value
Related