getDevices method

Future<List<Device>> getDevices({
  1. String? type,
  2. Duration timeout = const Duration(seconds: 5),
  3. bool silent = true,
})

Implementation

Future<List<Device>> getDevices(
    {String? type,
    Duration timeout = const Duration(seconds: 5),
    bool silent = true}) async {
  final results = await discoverDevices(type: type, timeout: timeout);

  final list = <Device>[];
  for (var result in results) {
    try {
      final device = await result.getRealDevice();

      if (device == null) {
        continue;
      }
      list.add(device);
    } catch (e) {
      if (!silent) {
        rethrow;
      }
    }
  }

  return list;
}