type 'String' is not a subtype of type 'Source


I have url of music stored in the firestore. Below in the code I am trying to play audio as per the url but I am unable to play the audio and I am getting Unhandled Exception: type ‘String’ is not a subtype of type ‘Source’. I am using audiplayers package.

 Row (
          mainAxisAlignment:  MainAxisAlignment.spaceBetween,
          children: [
              radius: 35,
                child: IconButton(
                  icon: Icon(isPlaying ? Icons.pause: Icons.play_arrow_rounded), onPressed: () async{
                    if (isPlaying){
                      await audioPlayer.pause();
                    } else {

                 await audioPlayer.play(widget.music);




play method requires Source class as a parameter. E.g. with a remote url:

await audioPlayer.play(UrlSource(widget.music));

Answered By – user18309290

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published