showSwitchAudioDialog function
Implementation
Future<void> showSwitchAudioDialog(BuildContext context, EnxController obj) async {
try {
await showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
builder: (BuildContext context) {
return Obx(() => Padding(
padding: const EdgeInsets.only(bottom: 120.0, left: 10, right: 10),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(width: 1.0),
borderRadius: const BorderRadius.all(Radius.circular(15.0)),
),
child: ListView(
shrinkWrap: true,
children: [
for (var item in obj.mediaDeviceList)
RadioListTile<MediaDeviceModel>(
title: Text(
item.name,
style: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.w800,
fontSize: 16,
),
),
value: item,
groupValue: obj.selectedMediaDeviceModel.value,
activeColor: Colors.red,
selected: obj.selectedMediaDeviceModel.value == item,
onChanged: (selected) {
if (selected != null) {
obj.selectedMediaDeviceModel.value = selected;
obj.selectedDevice.value = selected.name;
}
Get.back(); // Close modal after selection
},
),
],
),
),
));
},
);
} catch (e) {
// Handle any errors or exceptions here
}
}