Your experience on this site will be improved by allowing cookies
To add images from the camera in flutter, we’ll use the image_picker package. For this, you’ll need to use your real device.
Follow the below steps to display the images from the camera:
Step 1: Create a new flutter application.
flutter create
Step 2: Delete the default code from the main.dart file.
Step 3: Add the dependency to your pubspec.yaml file:
Step 4: Use the below code in the main.dart file :
main.dart:
|
Output:
When no image is selected, it will result:
When the button is tapped, the mobile’s camera will be opened to capture the image as shown below:
When the image is captured, it will be displayed on the screen as shown below:
0 comments