argument type 'String?' can't be assigned to the parameter type 'String'

Viewed 89

The argument type 'String?' can't be assigned to the parameter type 'String' i got this error but previously the code was working fine. i have seen people raising the same issue but am not understanding the root cause. the package am using is flutter_audio_query nullsafe version from github. can someone help me with the issue. enter image description here

1 Answers

String? which is nullable and you cannot pass directly to the non-null fields. So use like this,

await player.setUrl(songInfo.uri ?? ''); // if null then empty string will be passed.

or

await player.setUrl(songInfo.uri!); // this is you saying that it won't be null.
Related