Alikula
Alikula

Reputation: 458

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

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

Upvotes: 2

Views: 113

Answers (1)

Mohan Sai Manthri
Mohan Sai Manthri

Reputation: 3189

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.

Upvotes: 1

Related Questions