Home > other >  PlatformException (PlatformException(already_active, Image picker is already active, null, null))
PlatformException (PlatformException(already_active, Image picker is already active, null, null))

Time:09-03

In my flutter project I am getting exception whenever I am trying to pickup an image either from Camera or Gallery using the image_picker plugin of flutter. If I try to choose the camera or gallery even after restarting the app.

enter image description here

Below are the dependencies:

dependencies:
  flutter:
    sdk: flutter
  bloc: ^8.1.0
  flutter_bloc: ^8.1.1
  shared_preferences: ^2.0.15
  convex_bottom_bar: ^3.0.0
  pie_chart: ^5.3.2
  syncfusion_flutter_charts: ^20.2.46


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  http: ^0.13.5
  charts_flutter: ^0.12.0
  google_fonts: ^3.0.1
  survey_kit: ^0.1.1
  splash_screen_view: ^3.0.0
  intl: ^0.17.0
  image_picker: ^0.8.5 3
  path_provider: ^2.0.11
  dotted_border: ^2.0.0 2

CodePudding user response:

Make sure you add all permission to access the camera and storage memory on the release mode.

Android: in src/main/AndroidManifest.xml: inside the manifest tag, add this:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

IOS: inside file Info.plist add these:

<key>NSCameraUsageDescription</key>
<string>Allow access to camera to capture photos</string>

<key>NSPhotoLibraryUsageDescription</key>
<string>Allow access to photo library</string>

And after that run flutter clean and flutter pub get.

CodePudding user response:

Looks like you start ImagePicker more than once, put a logline before ImagePicker().pickImage and you should see if it gets called again before you finished the first one.

  • Related