find static method

Stream<DialScreen> find({
  1. bool silent = true,
})

Returns a stream of discovered devices with DIAL capabilities. Already found devices won't be added again to the stream. If silent, no exceptions will be passed to the returned stream.

Implementation

static Stream<DialScreen> find({bool silent = true}) async* {
  final discovery = DeviceDiscoverer();
  final ids = <String?>{};

  await for (DiscoveredClient client in discovery.quickDiscoverClients(
      timeout: const Duration(seconds: 5), query: CommonDevices.dial)) {
    if (ids.contains(client.usn)) {
      continue;
    }
    ids.add(client.usn);

    try {
      final dev = await (client.getDevice() as FutureOr<Device>);
      yield DialScreen(
          Uri.parse(Uri.parse(client.location!).origin), dev.friendlyName);
    } catch (e) {
      if (!silent) {
        rethrow;
      }
    }
  }
}