Building the camera preview

We will now build the camera preview for the application. We start by creating a new file, generate_live_caption.dartwith a GenerateLiveCaption stateful widget.

Let us look at the following steps to create a live camera preview:

  1. To add a live camera preview, we will be using the camera plugin. We begin by adding the dependency to the pubspec.yaml file, as follows:
camera: ^0.5.7

Next, we need to add the dependency to the project by running flutter pub get.

  1. We now create a new file, generate_live_captions.dartcontaining a GenerateLiveCaptions stateful widget. All of the code described in the further steps will be included in the _GenerateLiveCaptionState class.

 

  1. Import the camera library. We import it ...

Get Mobile Deep Learning with TensorFlow Lite, ML Kit and Flutter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.