Home > OS >  The argument type 'TextStyle?' can't be assigned to the parameter type 'TextStyl
The argument type 'TextStyle?' can't be assigned to the parameter type 'TextStyl

Time:04-02

I am getting this error...

code snippet that is throwing this error:

catalog.desc.text.textStyle(context.captionStyle).make(),

CodePudding user response:

Your object context.captionStyle has the TextStyle? type, which means it can be null. The .textStyle() function only accepts TextStyle objects, hence the error.

You either have to make sure that context.captionStyle is not null before trying to pass it to .textStyle(), or assuring the compiler it will never be null by writing .textStyle(context.captionStyle!) (but you will still get an error if it becomes null somehow).

  • Related