Home:ALL Converter>Camera crashes when Flutter App opened on Chrome on Mac

Camera crashes when Flutter App opened on Chrome on Mac

Ask Time:2022-05-14T17:12:59         Author:Subhraneel

Json Formatter

I have implemented code which will allow me to access the camera in my flutter application and it is working perfectly when the app is opened on android, but the app crashes and throws an exception when I open the same, on Chrome on Mac!

I am using camera package from flutter docs to access the camera!

import 'package:camera/camera.dart';

The exception occurs at this line:

List<CameraDescription> cameras = await availableCameras();

I don't know whether camera package supports on web or not, so if this is the case, can anyone suggest me an alternative, which I can use in web and a way how to write a condition, like if the app opened on web then the alternative camerapreview, else (on android) camerapreview from camera package

Edit - when I accept the permission of camera on chrome, the light of the webcam blinks and then the app crashes and points to the above line showcasing exception occurs

Author:Subhraneel,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72238807/camera-crashes-when-flutter-app-opened-on-chrome-on-mac
yy