0
'''

i Just want create a button that controlls the audio play pause state please some body let me know how can i do that?

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("ListView.builder")),
      body: ListView.builder(
        itemCount: radioDetails.length,
        itemBuilder: (BuildContext context, int index) {
          return Card(
            clipBehavior: Clip.antiAlias,
            child: ListTile(
                title: Text(radioDetails[index].name),
                trailing: IconButton(
                  icon: null as Widget,
                  onPressed: null,
                )),
          );
        },
      ),
    );
  }
}
Jonas
  • 121,568
  • 97
  • 310
  • 388
Afthal Ad
  • 91
  • 1
  • 7

1 Answers1

0

Create a bool

bool isPlaying = false;

In place of icon check this variable

icon: (isPlaying)? Icons.stop: Icons.play,
onTap: (){
  setState((){
    isPlaying = !isPlaying;
    //Manage playerto stop or play audio here
  });
}
Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30
  • can answer for my another question https://stackoverflow.com/questions/73003154/every-button-changes-at-once-in-listview-builder-but-i-want-to-operate-specifica – Afthal Ad Jul 16 '22 at 10:51