Skip to content

Commit

Permalink
[image_picker_for_web] Add doc comments to point out that some argume…
Browse files Browse the repository at this point in the history
…nts aren't supported on the web (flutter#3566)

Re-landing a PR that @ditman messed up!

flutter#3566

Co-authored-by: Jens Becker <jensbecker01@gmx.de>
Co-authored-by: Chris Yang <ychris@google.com>
  • Loading branch information
3 people authored and adsonpleal committed Feb 26, 2021
1 parent c7514d2 commit 774e04c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/image_picker/image_picker_for_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.0.0-nullsafety.1

* Add doc comments to point out that some arguments aren't supported on the web.

# 2.0.0-nullsafety

* Migrate to null safety.
Expand Down
8 changes: 7 additions & 1 deletion packages/image_picker/image_picker_for_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A web implementation of [`image_picker`][1].

## Browser Support
## Limitations on the web platform

Since Web Browsers don't offer direct access to their users' file system,
this plugin provides a `PickedFile` abstraction to make access access uniform
Expand Down Expand Up @@ -42,6 +42,12 @@ In order to "take a photo", some mobile browsers offer a [`capture` attribute](h
Each browser may implement `capture` any way they please, so it may (or may not) make a
difference in your users' experience.

### pickImage()
The arguments `maxWidth`, `maxHeight` and `imageQuality` are not supported on the web.

### pickVideo()
The argument `maxDuration` is not supported on the web.

## Usage

### Import the package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ class ImagePickerPlugin extends ImagePickerPlatform {
ImagePickerPlatform.instance = ImagePickerPlugin();
}

/// Returns a [PickedFile] with the image that was picked.
///
/// The `source` argument controls where the image comes from. This can
/// be either [ImageSource.camera] or [ImageSource.gallery].
///
/// Note that the `maxWidth`, `maxHeight` and `imageQuality` arguments are not supported on the web. If any of these arguments is supplied, it'll be silently ignored by the web version of the plugin.
///
/// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera].
/// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device.
/// Defaults to [CameraDevice.rear].
///
/// If no images were picked, the return value is null.
@override
Future<PickedFile> pickImage({
required ImageSource source,
Expand All @@ -42,6 +54,18 @@ class ImagePickerPlugin extends ImagePickerPlatform {
return pickFile(accept: _kAcceptImageMimeType, capture: capture);
}

/// Returns a [PickedFile] containing the video that was picked.
///
/// The [source] argument controls where the video comes from. This can
/// be either [ImageSource.camera] or [ImageSource.gallery].
///
/// Note that the `maxDuration` argument is not supported on the web. If the argument is supplied, it'll be silently ignored by the web version of the plugin.
///
/// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera].
/// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device.
/// Defaults to [CameraDevice.rear].
///
/// If no images were picked, the return value is null.
@override
Future<PickedFile> pickVideo({
required ImageSource source,
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker_for_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: image_picker_for_web
description: Web platform implementation of image_picker
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker_for_web

version: 2.0.0-nullsafety
version: 2.0.0-nullsafety.1

flutter:
plugin:
Expand Down

0 comments on commit 774e04c

Please sign in to comment.