I’m using flutter_vlc_player to cast a video to a device, but I’m encountering an issue where it says “device not found.” Here’s the code snippet where I attempt to get renderer devices and cast to them:
Future<void> _getRendererDevices() async {
final castDevices = await controller.getRendererDevices();
//
if (castDevices.isNotEmpty) {
if (!mounted) return;
final selectedCastDeviceName = await showDialog<String>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Display Devices'),
content: SizedBox(
width: double.maxFinite,
height: 250,
child: ListView.builder(
itemCount: castDevices.keys.length + 1,
itemBuilder: (context, index) {
return ListTile(
title: Text(
index < castDevices.keys.length
? castDevices.values.elementAt(index)
: 'Disconnect',
),
onTap: () {
Navigator.pop(
context,
index < castDevices.keys.length
? castDevices.keys.elementAt(index)
: null,
);
},
);
},
),
),
);
},
);
if (selectedCastDeviceName != null) {
await controller.castToRenderer(selectedCastDeviceName);
}
} else {
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('No Display Device Found!')),
);
}}
I expected this code to display a list of available devices and allow me to cast the video. However, I’m getting a “No Display Device Found!” message.
Could someone please suggest alternative solutions for video casting in Flutter, or help troubleshoot why flutter_vlc_player might not be detecting devices correctly?