showAudioDeviceDialog method

Future<void> showAudioDeviceDialog(
  1. BuildContext context
)

Implementation

Future<void> showAudioDeviceDialog(BuildContext context) async {
  String? device = await showModalBottomSheet(
      context: context,
      builder: (context) {
        var selected = MeetingModel().selectedAudioDevice;
        var selectedIcon = Icon(
          Icons.check,
          color: MeetingTheme().audioActiveColor,
        );
        var items = MeetingModel()
            .deviceList
            .whereType<String>()
            .map((e) => ListTile(
                  leading: Icon(
                    e.toLowerCase().contains('speaker')
                        ? Icons.volume_up_outlined
                        : Icons.hearing_outlined,
                  ),
                  title: Text(e),
                  onTap: () {
                    Navigator.pop(context, e);
                  },
                  trailing: selected == e ? selectedIcon : null,
                ))
            .toList();
        // TODO find the way to turn off sound
        // items.add(ListTile(
        //   leading: const Icon(Icons.volume_off_outlined),
        //   title: const Text('Turn off sound'),
        //   onTap: () {
        //     Navigator.pop(context, '');
        //   },
        //   trailing: selected == '' ? selectedIcon : null,
        // ));
        return SizedBox(
          height: 200,
          child: ListView(
            padding: const EdgeInsets.all(8),
            children: items,
          ),
        );
      });
  if (device == null) {
    return;
  }

  MeetingModel().updateCurrentDevice(device);
}