camera_web 0.2.0 copy "camera_web: ^0.2.0" to clipboard
camera_web: ^0.2.0 copied to clipboard

outdated

A Flutter plugin for getting information about and controlling the camera on Web.

Camera Web Plugin #

The web implementation of camera.

Note: This plugin is under development. See missing implementation.

Usage #

Depend on the package #

This package is not an endorsed implementation of the google_maps_flutter plugin yet, so you'll need to add it explicitly.

Example #

Find the example in the camera package.

Limitations on the web platform #

Camera devices #

The camera devices are accessed with Stream Web API with the following browser support:

Data on support for the Stream feature across the major browsers from caniuse.com

Accessing camera devices requires a secure browsing context. Broadly speaking, this means that you need to serve your web application over HTTPS (or localhost for local development). For insecure contexts CameraPlatform.availableCameras might throw a CameraException with the permissionDenied error code.

Device orientation #

The device orientation implementation is backed by Screen Orientation Web API with the following browser support:

Data on support for the Screen Orientation feature across the major browsers from caniuse.com

For the browsers that do not support the device orientation:

  • CameraPlatform.onDeviceOrientationChanged returns an empty stream.
  • CameraPlatform.lockCaptureOrientation and CameraPlatform.unlockCaptureOrientation throw a PlatformException with the orientationNotSupported error code.

Flash mode and zoom level #

The flash mode and zoom level implementation is backed by Image Capture Web API with the following browser support:

Data on support for the Image Capture feature across the major browsers from caniuse.com

For the browsers that do not support the flash mode:

  • CameraPlatform.setFlashMode throws a PlatformException with the torchModeNotSupported error code.

For the browsers that do not support the zoom level:

  • CameraPlatform.getMaxZoomLevel, CameraPlatform.getMinZoomLevel and CameraPlatform.setZoomLevel throw a PlatformException with the zoomLevelNotSupported error code.

Taking a picture #

The image capturing implementation is backed by URL.createObjectUrl Web API with the following browser support:

Data on support for the Blob URLs feature across the major browsers from caniuse.com

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));
}

Missing implementation #

The web implementation of camera is missing the following features:

  • Video recording (in progress)
  • Exposure mode, point and offset
  • Focus mode and point
  • Sensor orientation
  • Image format group
  • Streaming of frames
84
likes
0
pub points
98%
popularity

Publisher

verified publisherflutter.dev

A Flutter plugin for getting information about and controlling the camera on Web.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

camera_platform_interface, flutter, flutter_web_plugins, stream_transform

More

Packages that depend on camera_web