takePicture method
Captures a static image and returns its path.
Implementation
@override
Future<String?> takePicture() async {
if (_videoElement == null) return null;
final video = _videoElement!;
// Draw the current video frame onto a canvas
final canvas = web.HTMLCanvasElement();
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
final ctx = canvas.getContext('2d') as web.CanvasRenderingContext2D?;
if (ctx == null) return null;
ctx.drawImage(video, 0, 0);
// Export as data URL → convert to XFile-friendly blob URL
final quality = (_quality * 100).round() / 100;
final dataUrl = canvas.toDataURL('image/jpeg', quality.toJS);
return dataUrl; // On web we return a data: URI as the "path"
}