Member-only story
Capturing Photos Using the Camera in Flutter
Bring your camera into your app

In the last post, I discussed how to select an image from the photo library using the Image Picker package in Flutter. It worked great and we were able to display the image in our application.
In this final part, I will demonstrate how you can capture a photo using the phone’s camera and display it on the screen. It is highly recommended that you read the first part because a lot of configuration and permission requests were discussed in the earlier post.
Getting Started
The first step is to install the camera plugin. The camera plugin will allow us to use the physical camera on the device and capture photos. Start by adding camera dependency to the pubspec.yaml file as shown in the implementation below:
Next, we need to update the _showOptions method to take into account when the user selects Take a Picture from Camera option. The implementation is shown below:
The _showCamera method is responsible for getting access to the available cameras and then taking the user to a separate view to preview the photo. The first camera is going to be the back-facing camera.
Currently, the TakePicturePage does not exist. The TakePicturePage will be responsible for allowing the user to capture the photo using their camera. In the next section, you will learn how to show the camera preview to the user and then send the captured photo back to the HomePage so it can…