start method
Future<int?>
start({
- CameraQuality quality = CameraQuality.hd,
- int? width,
- int? height,
- bool autoRequestPermission = true,
Starts the camera and returns the native textureId for rendering.
Use the returned ID with a Texture widget for high-performance preview. Returns null if the camera failed to start.
Implementation
Future<int?> start({
CameraQuality quality = CameraQuality.hd,
int? width,
int? height,
bool autoRequestPermission = true,
}) async {
if (width != null && width <= 0) {
throw ArgumentError.value(width, 'width', 'Must be greater than zero.');
}
if (height != null && height <= 0) {
throw ArgumentError.value(height, 'height', 'Must be greater than zero.');
}
return _mutex.protect(() async {
if (autoRequestPermission) {
final granted = await NexoraSdkPlatform.instance
.requestCameraPermission();
if (!granted) return null;
}
return NexoraSdkPlatform.instance
.startCamera(
width: width ?? quality.width,
height: height ?? quality.height,
)
.then((result) {
if (result is int) {
_isRunning = true;
return result;
}
return null;
});
});
}