Wenn ich mit dem Code_Scan Package in Flutter einen QR_Code scanne, dann wird in Flutter in der camera_controller.dart eine Exception geworfen. 

code: "Disposed CameraController" 
"stopImageStream() was called on a disposed CameraController."

 if (_isDisposed) {
      throw CameraException(
        'Disposed CameraController',
        '$functionName() was called on a disposed CameraController.',
      );
    }

import 'dart:io';
import 'dart:math';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/patient_app_localizations.dart';
import 'package:patient_app/models/scan_result.dart';
import 'package:patient_app/theme/patient_app_colors.dart';
import 'package:patient_app/theme/patient_app_theme.dart' as theme;
import 'package:patient_app/widgets/patient_app_back_button.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';

typedef QrScanResultCallback = Future<bool> Function(ScanResult);

// see https://pub.dev/packages/qr_code_scanner/example
class QrScanner extends StatefulWidget {
  const QrScanner(
      {Key? key, required this.callback, required this.backButtonCallback})
      : super(key: key);

  final QrScanResultCallback callback;
  final BackButtonCallback backButtonCallback;

  @override
  State<QrScanner> createState() => _QrScannerState();
}

class _QrScannerState extends State<QrScanner> {
  QRViewController? controller;
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');

  late AppLocalizations _l10n;

  @override
  void didChangeDependencies() {
    _l10n = AppLocalizations.of(context)!;
    super.didChangeDependencies();
  }

  @override
  void dispose() {
    controller?.dispose();
    super.dispose();
  }

  // In order to get hot reload to work we need to pause the camera if the platform
  // is android, or resume the camera if the platform is iOS.
  @override
  void reassemble() {
    super.reassemble();
    if (defaultTargetPlatform == TargetPlatform.android) {
      controller!.pauseCamera();
    }
    controller!.resumeCamera();
  }

  @override
  Widget build(BuildContext context) {
    double cutOutSize = _calculateCutOutSize(context);

    return Container(
      color: AppColors.opascaBlue,
      child: Stack(
        children: [
          _buildQrView(cutOutSize),
          _flashlightButton(cutOutSize),
        ],
      ),
    );
  }

  double _calculateCutOutSize(BuildContext context) {
    var minimumAvailableSpace = min(
        MediaQuery.of(context).size.width, MediaQuery.of(context).size.height);
    return minimumAvailableSpace - (2 * theme.mediumPadding);
  }

  Widget _flashlightButton(double cutOutSize) {
    return Positioned.fill(
      top: (MediaQuery.of(context).size.height * 0.5) + (cutOutSize * 0.5),
      child: Align(
        alignment: Alignment.topCenter,
        child: FloatingActionButton(
          onPressed: () async {
            try {
              await controller?.toggleFlash();
            } catch (e) {
              _showSnackBar(const ValueKey('flashlight'),
                  'Flashlight toggle not possible');
            }
            setState(() {});
          },
          elevation: 0.0,
          backgroundColor: AppColors.transparent,
          child: FutureBuilder(
            future: controller?.getFlashStatus(),
            builder: (context, snapshot) {
              if (snapshot.data == true) {
                return const Icon(Icons.flash_off);
              }
              return const Icon(Icons.flash_on);
            },
          ),
        ),
      ),
    );
  }

  Widget _buildQrView(double cutOutSize) {
    // For this example we check how width or tall the device is and change the scanArea and overlay accordingly.
    var cutOutBottomOffset = theme.mediumSpacing;
    return QRView(
      key: qrKey,
      onQRViewCreated: _onQRViewCreated,
      overlay: QrScannerOverlayShape(
        borderRadius: theme.radiusValue,
        borderLength: theme.scannerOverlayBorderLength,
        borderWidth: theme.scannerOverlayBorderWidth,
        cutOutSize: cutOutSize,
        cutOutBottomOffset: cutOutBottomOffset,
        overlayColor: AppColors.blackOpacity60,
      ),
      onPermissionSet: (_, permissionGranted) =>
          _onPermissionSet(permissionGranted),
    );
  }

  void _onQRViewCreated(QRViewController controller) {
    this.controller?.dispose();
    setState(() {
      this.controller = controller;
    });
    controller.scannedDataStream.listen((scanData) async {
      if (scanData.code != null) {
        this.controller?.pauseCamera();
        bool resultHandled = await widget.callback(ScanResult(scanData.code!));
        if (!resultHandled) {
          await _showQrCodeReadErrorDialog();
          this.controller?.resumeCamera();
        }
      }
    });
    if (Platform.isAndroid) {
      // https://github.com/juliuscanute/qr_code_scanner/issues/560
      // fix for android camera, black screen
      controller.pauseCamera();
      controller.resumeCamera();
    }
  }

  Future<dynamic> _showQrCodeReadErrorDialog() {
    return showDialog(
      context: context,
      builder: (_) => AlertDialog(
        title: Text(_l10n.accountLinking_QrCodeScannerDialogTitle),
        content: Text(_l10n.accountLinking_QrCodeScannerDialogDescription),
        actions: [
          TextButton(
            onPressed: () {
              Navigator.pop(context);
            },
            child: Text(_l10n.accountLinking_QrCodeScannerDialogAction),
          )
        ],
      ),
    );
  }

  void _onPermissionSet(bool permissionGranted) async {
    if (!permissionGranted) {
      await _showPermissionNotGrantedDialog();
      controller?.pauseCamera();
      widget.backButtonCallback();
    }
  }

  Future<dynamic> _showPermissionNotGrantedDialog() {
    return showDialog(
      context: context,
      builder: (_) => AlertDialog(
        title: Text(
            _l10n.accountLinking_QrCodeScannerMissingCameraPermissionTitle),
        content: Text(_l10n
            .accountLinking_QrCodeScannerMissingCameraPermissionDescription),
        actions: [
          TextButton(
            onPressed: () {
              Navigator.pop(context);
            },
            child: Text(_l10n.accountLinking_QrCodeScannerDialogAction),
          )
        ],
      ),
    );
  }

  void _showSnackBar(Key key, String text) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        key: key,
        content: Text(text),
      ),
    );
  }
}

import 'dart:async';

import 'package:code_scan/code_scan.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/patient_app_localizations.dart';
import 'package:patient_app/models/scan_result.dart';
import 'package:patient_app/theme/patient_app_colors.dart';
import 'package:patient_app/widgets/patient_app_back_button.dart';

typedef QrScanResultCallback = Future<bool> Function(ScanResult);

// see https://pub.dev/packages/code_scan/example
class QrScanner extends StatefulWidget {
  const QrScanner(
      {Key? key, required this.callback, required this.backButtonCallback})
      : super(key: key);

  final QrScanResultCallback callback;
  final BackButtonCallback backButtonCallback;

  @override
  State<QrScanner> createState() => _QrScannerState();
}

class _QrScannerState extends State<QrScanner> with WidgetsBindingObserver {
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
  late AppLocalizations _l10n;

  // prevent over processing
  bool processingInProgress = false;

  @override
  void didChangeDependencies() {
    _l10n = AppLocalizations.of(context)!;
    super.didChangeDependencies();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: AppColors.opascaBlue,
      child: _buildQrView(),
    );
  }

  Widget _buildQrView() {
    return CodeScanner(
      key: qrKey,
      formats: const [BarcodeFormat.qrCode],
      scanInterval: const Duration(milliseconds: 500),
      onScan: (code, _, listener) {
        if (code != null) {
          if (processingInProgress == false) {
            processingInProgress = true;
            widget.callback(ScanResult(code)).then((isValidCode) {
              if (mounted && !isValidCode) {
                processingInProgress = false;
              }
            });
          }
        }
      },
      onAccessDenied: (_, controller) {
        _showPermissionNotGrantedDialog()
            .then((_) => widget.backButtonCallback());
        return false;
      },
      onError: (_, __) {
        _showQrCodeReadErrorDialog();
      },
      overlay: Container(),
    );
  }

  Future<dynamic> _showQrCodeReadErrorDialog() {
    return showDialog(
      context: context,
      builder: (_) => AlertDialog(
        title: Text(_l10n.accountLinking_QrCodeScannerDialogTitle),
        content: Text(_l10n.accountLinking_QrCodeScannerDialogDescription),
        actions: [
          TextButton(
            onPressed: () {
              Navigator.pop(context);
            },
            child: Text(_l10n.accountLinking_QrCodeScannerDialogAction),
          )
        ],
      ),
    );
  }

  Future<dynamic> _showPermissionNotGrantedDialog() {
    return showDialog(
      context: context,
      builder: (_) => AlertDialog(
        title: Text(
            _l10n.accountLinking_QrCodeScannerMissingCameraPermissionTitle),
        content: Text(_l10n
            .accountLinking_QrCodeScannerMissingCameraPermissionDescription),
        actions: [
          TextButton(
            onPressed: () {
              Navigator.pop(context);
            },
            child: Text(_l10n.accountLinking_QrCodeScannerDialogAction),
          )
        ],
      ),
    );
  }
}