This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[camera_web] Update the web plugin README (#4237)
* docs: update web plugin README * docs: update web plugin missing implementation README
- Loading branch information
Showing
1 changed file
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,77 @@ | ||
# Camera Web Plugin | ||
|
||
A Flutter plugin for Web allowing access to the device cameras. | ||
The web implementation of [`camera`][camera]. | ||
|
||
*Note*: This plugin is under development. | ||
*Note*: This plugin is under development. See [missing implementation](#missing-implementation). | ||
|
||
In order to use this plugin, your app should depend both on `camera` and `camera_web`. This is a temporary solution until a plugin is released. | ||
## Usage | ||
|
||
This package is [endorsed](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin), which means you can simply use `camera` normally. This package will be automatically included in your app when you do. | ||
|
||
## Example | ||
|
||
Find the example in the [`camera` package](https://pub.dev/packages/camera#example). | ||
|
||
## Limitations on the web platform | ||
|
||
### Camera devices | ||
|
||
The camera devices are accessed with [Stream Web API](https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API) with the following [browser support](https://caniuse.com/stream): | ||
|
||
![Data on support for the Stream feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/stream.png) | ||
|
||
Accessing camera devices requires a [secure browsing context](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts). This means that you might need to serve your web application over HTTPS. 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`](https://www.w3.org/TR/screen-orientation/) with the following [browser support](https://caniuse.com/screen-orientation): | ||
|
||
![Data on support for the Screen Orientation feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/screen-orientation.png) | ||
|
||
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](https://w3c.github.io/mediacapture-image/) with the following [browser support](https://caniuse.com/mdn-api_imagecapture) (as of 12 August 2021): | ||
|
||
![Data on support for the Image Capture feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/static/v1/mdn-api__ImageCapture-1628778966589.png) | ||
|
||
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](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) with the following [browser support](https://caniuse.com/bloburls): | ||
|
||
![Data on support for the Blob URLs feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/bloburls.png) | ||
|
||
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 and should be displayed using `Image.network` or `Image.memory` after loading the image bytes to memory. | ||
|
||
See the example below: | ||
|
||
```dart | ||
if (kIsWeb) { | ||
Image.network(capturedImage.path); | ||
} else { | ||
Image.file(File(capturedImage.path)); | ||
} | ||
``` | ||
|
||
## Missing implementation | ||
|
||
The web implementation of [`camera`][camera] is missing the following features: | ||
- Video recording | ||
- Exposure mode, point and offset | ||
- Focus mode and point | ||
- Camera closing events | ||
- Camera sensor orientation | ||
- Camera image format group | ||
- Camera image streaming | ||
|
||
<!-- Links --> | ||
[camera]: https://pub.dev/packages/camera |