'Flutter CameraPreview freezes when reopening the app

I followed this tutorial here: https://docs.flutter.dev/cookbook/plugins/picture-using-camera

Everything works fine but after reopening the app after some time the cameraPreview-part freezes. I read about adding a didChangeAppLifecycleState method but this only caused more problems like a totally black screen when reopening.

flutter doctor: version

Flutter (Channel stable, 2.10.3, on Ubuntu 20.04.4 LTS 5.13.0-35-generic, locale en_US.UTF-8)

pubspec.yaml: versions

camera: ^0.9.4+16
path: ^1.8.0
path_provider: ^2.0.9

I'm mainly running on my Redmi Note 8T but this problem also occurs on my emulator.

TY :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source