sc4v3ng3r / flutter_audio_query

Flutter Audio Query Plugin
https://pub.dev/packages/flutter_audio_query
MIT License
52 stars 48 forks source link

getSongsById #16

Closed ahmedaslam11 closed 3 years ago

ahmedaslam11 commented 4 years ago

crash application if memberIds contain only one song title.

sc4v3ng3r commented 4 years ago

membersIds property must not be the song titles. It must be the song ID(s) value(s).

ahmedaslam11 commented 4 years ago
getSongsFromIds(List<String> memberIds) async {
    print('memberIds:${memberIds.length}');
    if (memberIds.length == 0) {
      _songsFromIds = [];
    } else {
      print("here");
      print(memberIds.toString());
      _songsFromIds = await audioQuery.getSongsById(ids: memberIds);
      print(_songsFromIds.toString());
      notifyListeners();
    }
  } 

Capture

ahmedaslam11 commented 4 years ago

if there are more than one memberId than it work fine. But there is only one memberId app crashes.

geisterfurz007 commented 4 years ago

Yup, I am facing the same issue.

await FlutterAudioQuery().getSongsById(ids: ["0"]);

is all it takes to crash it.

I/System.out(32097): SongLoader::basicLoad java.lang.IllegalArgumentException: Cannot bind argument at index 1 because the index is out of range.  The statement has 0 parameters.

is probably the best attempt at an error message I got.

geisterfurz007 commented 4 years ago

@ahmedaslam11 what appears to be a usable workaround is to add an empty string in case the list of ids has length 1. It's not ideal but works until this might be resolved in the future.

sc4v3ng3r commented 3 years ago

fixed and closed #37