pickDevice static method
UCameraDevice?
pickDevice(
- List<
UCameraDevice> devices, { - UCameraFacing facing = UCameraFacing.back,
- UCameraLens? lens,
Picks the device closest to facing, preferring the given lens.
Implementation
static UCameraDevice? pickDevice(List<UCameraDevice> devices, {UCameraFacing facing = UCameraFacing.back, UCameraLens? lens}) {
if (devices.isEmpty) return null;
UCameraDevice? fallback;
for (final UCameraDevice device in devices) {
if (device.facing != facing) continue;
if (lens == null || device.lens == lens) return device;
fallback ??= device;
}
return fallback ?? devices.first;
}