startDiscovery static method

Future<bool> startDiscovery({
  1. required dynamic onDevices(
    1. List<TVDevice>
    ),
})

Implementation

static Future<bool> startDiscovery({
  required Function(List<TVDevice>) onDevices,
}) async {
  channel.setMethodCallHandler((call) async {
    if (call.method == 'devicesDiscovered') {
      final list = (call.arguments as List)
          .map((e) => TVDevice.fromMap(Map<String, dynamic>.from(e)))
          .toList();
      onDevices(list);
    }
  });

  final res = await channel.invokeMethod('startDiscovery');
  return (res as Map)['success'] == true;
}