Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In flutter when camera is opened from image picker the app "Lost connection to device."

When I go through opening up the camera to set profile image using image picker, the app crashes and I lost connection to device

:enter image description here

When pick up image from gallery its working fine,

my pubspec.yaml

  name: flutterapp
description: A new Flutter project.

# Prevent accidental publishing to pub.dev.
publish_to: 'none'

version: 1.0.0+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  
  connectivity: ^3.0.6
  flutter:
    sdk: flutter
 
  flutter_localizations:
    sdk: flutter
  font_awesome_flutter: 
  geolocator: ^7.7.0
  http: ^0.13.4
  
  image_picker: ^0.8.4+3
  local_auth: ^1.1.8
  path_provider: ^2.0.5
  pdf: ^3.6.0
  permission_handler: ^8.2.5
  shared_preferences: ^2.0.8
  

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^1.0.0

flutter:
  uses-material-design: true
  
  # Enable generation of localized Strings from arb files.
  generate: true

  assets:
    # Add assets from the images directory to the application.
    - assets/
like image 376
Vedha Avatar asked Sep 14 '25 22:09

Vedha


1 Answers

If you are using an iOS device then you have to add permission for image picking. Add these line in your info.plist file.

<key>NSCameraUsageDescription</key>
<string>Access to take a photo by camera</string>
<key>NSAppleMusicUsageDescription</key>
<string>Access to pick a photo</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Access to pick a photo</string>
like image 160
Nazmul Hasan Avatar answered Sep 16 '25 11:09

Nazmul Hasan