7

In my code :

final cameras = await availableCameras();
  // Get a specific camera from the list of available cameras.
  final firstCamera = cameras.first;

Package :

import 'package:camera/camera.dart';

Unhandled Exception: Bad state: No element

0 List.first (dart:core-patch/growable_array.dart:220:5)



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSCameraUsageDescription</key>
<string>Can I use the camera please?</string>
<key>NSMicrophoneUsageDescription</key>
<string>Can I use the mic please?</string>



Issue solved
In IOS camera is not available in emulator

2
  • have you asked permission for camera in info.plist ? Dec 3, 2019 at 6:53
  • @Sumeet.Jain yes, i added it and updated it in my question
    – Midhilaj
    Dec 3, 2019 at 7:14

1 Answer 1

5

The iOS Simulator doesn't have access to the camera. Trying to access it always results in a camera unavailable error. You'll notice that when trying to launch the camera app itself, you'll just get a static black screen with the UI but you can't take any pictures with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.