Flutter – How correctly pause camera when user moved to other (preview) screen?

Posted by Andre Scott | Updated on

Flutter – How correctly pause camera when user moved to other (preview) screen?

Have a variable like _cameraOn = true. Show CameraPreview when it is true and not when it is false. While navigating to another screen set it to false

You could have the camera related functionality in a separate widget. So every time it is displayed it is initialized, and when it is not it’s disposed.

A simple working example:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers