shoot method

Future<XFile> shoot()

Implementation

Future<XFile> shoot() async {
  if (_isProcessing) {
    throw Exception("Kamera arbeitet noch");
  }

  if (_controller == null || !_controller!.value.isInitialized) {
    debugPrint("Controller nicht initialisiert, starte Kamera...");
    await start();
  }

  try {
    _isProcessing = true;
    notifyListeners();

    // Haptisches Feedback bei Aufnahme
    HapticFeedback.mediumImpact();

    _latestPic = await _controller!.takePicture();

    _isProcessing = false;
    notifyListeners();
    return _latestPic!;
  } catch (e) {
    _isProcessing = false;
    notifyListeners();
    debugPrint("Fehler beim Aufnehmen des Bildes: $e");
    throw Exception("Fehler beim Aufnehmen des Bildes");
  }
}