Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Click items in listview #9

Open
nayyelin365 opened this issue Sep 25, 2021 · 2 comments
Open

No Click items in listview #9

nayyelin365 opened this issue Sep 25, 2021 · 2 comments

Comments

@nayyelin365
Copy link

I can not click items in listview

@suragch
Copy link
Owner

suragch commented Sep 27, 2021

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
Copy link

zionnite commented Nov 6, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants