[英]Play Pause icon in single button (Audioplayer flutter)
'''
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,
)),
);
},
),
);
}
}
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
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.