Midhilaj
Midhilaj

Reputation: 4987

availableCameras is empty in IOS but no problem in Android

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

Upvotes: 7

Views: 1663

Answers (1)

David L.
David L.

Reputation: 852

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.

Upvotes: 6

Related Questions