No Click items in listview
Opened this issue · 2 comments
nayyelin365 commented
I can not click items in listview
suragch commented
Yes, this tutorial doesn't cover that. However, you can add that functionality yourself by implementing _audioHandler.skipToQueueItem()
when the user taps a list view item.
zionnite commented
was able to do this @MgNayYELinUCS , this is what you need to do that's if you still need the code on how to do it.
class Playlist extends StatelessWidget {
const Playlist({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final pageManager = getIt<PageManager>();
return ValueListenableBuilder<List<String>>(
valueListenable: pageManager.playlistNotifier,
builder: (context, playlistTitles, _) {
return ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: ClampingScrollPhysics(),
itemCount: playlistTitles.length,
itemBuilder: (context, index) {
return Column(
children: [
InkWell(
onTap: () {
var current_id = pageManager.getCurrentSongId();
var current_playlist = pageManager.getCurrentPlaylist();
pageManager.skipToQueueItem(index, playlistTitles[index]);
// pageManager.updateMyQueueItem(
// current_playlist[int.parse(current_id)],
// int.parse(current_id),
// );
},
child: ListTile(
//leading: CurrentSongImage(),
title: Text(
'${playlistTitles[index]}',
),
//trailing: AddRemoveSongButtons(),
),
),
SizedBox(
height: 5,
)
],
);
},
);
},
);
}
}
page_manager.dart
void skipToQueueItem(int index, String name) {
_audioHandler.skipToQueueItem(index);
}
audio_handler.dart
@override
Future<void> skipToQueueItem(int index) async {
if (index < 0 || index >= queue.value!.length) return;
if (_player.shuffleModeEnabled) {
index = _player.shuffleIndices![index];
}
_player.seek(Duration.zero, index: index);
}
That's all and everything worked for me!