getSupportedLenses method
Get the set of supported camera lens types for the current device.
Returns a set of CameraLensType values that are available on the
device. This can be used to determine which lens types can be used
with the scanner.
Returns an empty set if the device has no cameras. On platforms
that do not support querying specific lens types, returns a set
containing only CameraLensType.any if cameras are available.
This method can be called before starting the scanner.
Throws a MobileScannerException if the controller has been disposed.
Example:
final supportedLenses = await controller.getSupportedLenses();
if (supportedLenses.isEmpty) {
print('No camera lenses available');
} else {
print('Available lenses: $supportedLenses');
}
Implementation
Future<Set<CameraLensType>> getSupportedLenses({
CameraFacing? facing,
}) async {
if (_isDisposed) {
throw MobileScannerException(
errorCode: MobileScannerErrorCode.controllerDisposed,
errorDetails: MobileScannerErrorDetails(
message: MobileScannerErrorCode.controllerDisposed.message,
),
);
}
return MobileScannerPlatform.instance.getSupportedLenses(facing: facing);
}