0
0
Fluttermobile~10 mins

Camera access in Flutter - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Flutter camera package.

Flutter
import 'package:[1]/camera.dart';
Drag options to blanks, or click blank then click option'
Acamera
Bflutter_camera
Cflutter_camera_plugin
Dcamera_access
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong or non-existent package name.
Forgetting to import the camera package.
2fill in blank
medium

Complete the code to get the list of available cameras asynchronously.

Flutter
final cameras = await [1].availableCameras();
Drag options to blanks, or click blank then click option'
AavailableCameras
BCamera
CCameraController
Attempts:
3 left
💡 Hint
Common Mistakes
Calling availableCameras() on the wrong class or instance.
Not using await for the asynchronous call.
3fill in blank
hard

Fix the error in initializing the CameraController with the first camera and resolution preset.

Flutter
controller = CameraController(cameras[[1]], ResolutionPreset.high);
Drag options to blanks, or click blank then click option'
A1
Bnull
C-1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 1 which may cause an out-of-range error.
Using negative or null index.
4fill in blank
hard

Complete the code to start the camera controller asynchronously and update the UI after initialization.

Flutter
await controller.[1]();
setState(() => {});
Drag options to blanks, or click blank then click option'
Ainitialize
B=>
C{}
D()
Attempts:
3 left
💡 Hint
Common Mistakes
Calling the wrong method to start the controller.
Using incorrect syntax for setState callback.
5fill in blank
hard

Fill all three blanks to display the camera preview widget inside a container with full width and height.

Flutter
return Container(
  width: double.[1],
  height: double.[2],
  child: CameraPreview([3]),
);
Drag options to blanks, or click blank then click option'
Ainfinity
Binfinite
Ccontroller
Dcontroller.value
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'infinite' instead of 'infinity'.
Passing the wrong object to CameraPreview.