Home > Enterprise >  Use camera for capture photo in flutter web
Use camera for capture photo in flutter web

Time:08-25

Im currently using this article : https://docs.flutter.dev/cookbook/plugins/picture-using-camera for capture photo on android and it works fine, also when i run my debug web app it will open the camera to take picture but when i build web , the camera won't open to capture photo! does any body face this problem ever?

CodePudding user response:

I hope you followed the documentation of camera plugin for web implementations too. There are some limitations of camera for web

For displaying the picture the documentation states

The web platform does not support dart:io. Attempts to display a captured image using Image.file will throw an error. The capture image contains a network-accessible URL pointing to a location within the browser (blob) and can be displayed using Image.network or Image.memory after loading the image bytes to memory.

See the example below:

if (kIsWeb) {
  Image.network(capturedImage.path);
} else {
  Image.file(File(capturedImage.path));
}

CodePudding user response:

Use following plugin for web support along with this.

https://pub.dev/packages/camera_web

Please check documentation for web integration here

https://pub.dev/packages/camera

  • Related