Viewing version 3.1.1. Open the latest package page.
image_picker_for_web
3.1.1Web platform implementation of image_picker
Readme
image_picker_for_web
A web implementation of image_picker.
Limitations on the web platform
XFile
This plugin uses XFile objects to abstract files picked/created by the user.
Read more about XFile on the web in
package:cross_file's README.
input file "accept"
In order to filter only video/image content, some browsers offer an accept attribute in their input type="file" form elements:
Data on support for the input-file-accept feature across the major browsers from caniuse.com
This feature is just a convenience for users, not validation.
Users can override this setting on their browsers. You must validate in your app (or server) that the user has picked the file type that you can handle.
input file "capture"
In order to "take a photo", some mobile browsers offer a capture attribute:
Data on support for the html-media-capture feature across the major browsers from caniuse.com
Each browser may implement capture any way they please, so it may (or may not) make a
difference in your users' experience.
input file "cancel"
The cancel event
used by the plugin to detect when users close the file selector without picking
a file is relatively new, and will only work in recent browsers.
ImagePickerOptions support
The ImagePickerOptions configuration object allows passing resize (maxWidth,
maxHeight) and quality (imageQuality) parameters to some methods of this
plugin, which in other platforms control how selected images are resized or
re-encoded.
On the web:
maxWidth,maxHeightandimageQualityare not supported forgifimages.imageQualityonly affectsjpgandwebpimages.
getVideo()
The argument maxDuration is not supported on the web.
Usage
Import the package
This package is endorsed,
which means you can simply use image_picker
normally. This package will be automatically included in your app when you do,
so you do not need to add it to your pubspec.yaml.
However, if you import this package to use any of its APIs directly, you
should add it to your pubspec.yaml as usual.
Use the plugin
You should be able to use package:image_picker almost as normal.
Once the user has picked a file, the returned XFile instance will contain a
network-accessible Blob URL (pointing to a location within the browser).
The instance will also let you retrieve the bytes of the selected file across all platforms.
If you want to use the path directly, your code would need look like this:
if (kIsWeb) {
image = Image.network(pickedFile.path);
} else {
image = Image.file(File(pickedFile.path));
}
Or, using bytes:
image = Image.memory(await pickedFile.readAsBytes());
Changelog
3.1.1
- Uses
CanvasRenderingContext2D.drawImageinstead of the deprecateddrawImageScaled. - Updates minimum supported SDK version to Flutter 3.32/Dart 3.8.
3.1.0
- Adds support for
getMultiVideoWithOptions. - Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.
3.0.6
- Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
- Extends the
mimepackage version constraint from^1.0.4to>=1.0.4 <3.0.0.
3.0.5
- Adds support for
web: ^1.0.0.
3.0.4
- Improves README example and updates it to use code excerpts.
3.0.3
- Migrates package and tests to
package:web. - Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.
3.0.2
- Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
- Removes input element after completion
3.0.1
- Adds pub topics to package metadata.
- Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.
3.0.0
- BREAKING CHANGE: Removes all code and tests mentioning
PickedFile. - Listens to
cancelevent on file selection. When the selection is canceled:Future<XFile?>methods returnnullFuture<List<XFile>>methods return an empty list.
2.2.0
- Adds
getMediamethod. - Updates minimum supported SDK version to Flutter 3.3/Dart 2.18.
2.1.12
- Clarifies explanation of endorsement in README.
- Aligns Dart and Flutter SDK constraints.
2.1.11
- Updates links for the merge of flutter/plugins into flutter/packages.
- Updates minimum Flutter version to 3.0.
2.1.10
- Updates code for
no_leading_underscores_for_local_identifierslint.
2.1.9
- Updates imports for
prefer_relative_imports. - Updates minimum Flutter version to 2.10.
- Fixes violations of new analysis option use_named_constants.
2.1.8
- Minor fixes for new analysis options.
2.1.7
- Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors lint warnings.
2.1.6
- Internal code cleanup for stricter analysis options.
2.1.5
- Removes dependency on
meta.
2.1.4
- Implemented
maxWidth,maxHeightandimageQualitywhen selecting images (except for gifs).
2.1.3
- Add
implementsto pubspec.
2.1.2
- Updated installation instructions in README.
2.1.1
- Implemented
getMultiImage. - Initialized the following
XFileattributes for picked files:name,length,mimeTypeandlastModified.
2.1.0
- Implemented
getImage,getVideoandgetFilemethods that returnXFileinstances. - Move tests to
exampledirectory, so they run as integration_tests withflutter drive.
2.0.0
- Migrate to null safety.
- Add doc comments to point out that some arguments aren't supported on the web.
0.1.0+3
- Update Flutter SDK constraint.
0.1.0+2
- Adds Video MIME Types for the safari browser for acception
0.1.0+1
- Remove
androiddirectory.
0.1.0
- Initial open-source release.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'image_picker_for_web:3.1.1'pubspec.yaml
name: image_picker_for_web
description: Web platform implementation of image_picker
repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_for_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
version: 3.1.1
environment:
sdk: ^3.8.0
flutter: ">=3.32.0"
flutter:
plugin:
implements: image_picker
platforms:
web:
pluginClass: ImagePickerPlugin
fileName: image_picker_for_web.dart
dependencies:
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter
image_picker_platform_interface: ^2.11.0
mime: ">=1.0.4 <3.0.0"
web: ">=0.5.1 <2.0.0"
dev_dependencies:
flutter_test:
sdk: flutter
topics:
- camera
- image-picker
- files
- file-selection
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | On demand | Download | 7c1ab316…080f16 |
| 0.1.0+1 | On demand | Download | 1fe458c3…d7a307 |
| 0.1.0+2 | On demand | Download | 7bac0654…3ab5ca |
| 2.0.0-nullsafety | On demand | Download | 95b07428…be5fb8 |
| 2.0.0 | On demand | Download | 3a19a450…f7bdbc |
| 2.1.0 | On demand | Download | 1a21500e…97f53e |
| 2.1.1 | On demand | Download | dad86416…b59fc4 |
| 2.1.2 | On demand | Download | 8c3ea4a4…5fe4cd |
| 2.1.3 | On demand | Download | 111b1405…139e10 |
| 2.1.4 | On demand | Download | 32414704…4f4ce2 |
| 2.1.5 | On demand | Download | 1f21a49e…bfb9f5 |
| 2.1.6 | On demand | Download | 837609cc…9a9333 |
| 2.1.7 | On demand | Download | 8c1fb06d…3fe26f |
| 2.1.8 | On demand | Download | 60f306ff…0f0e0e |
| 2.1.9 | On demand | Download | 0249a6f4…35bac8 |
| 2.1.10 | On demand | Download | 7d319fb7…863899 |
| 2.1.11 | On demand | Download | 66fc6e38…b85b34 |
| 2.1.12 | On demand | Download | 98f50d6b…2c081c |
| 2.2.0 | On demand | Download | 869fe8a6…c797f0 |
| 3.0.0 | On demand | Download | 8b6c160c…da8765 |
| 3.0.1 | On demand | Download | 50bc9ae6…347ef7 |
| 3.0.2 | On demand | Download | e2423c53…a730a3 |
| 3.0.3 | On demand | Download | 6a1704fd…eac954 |
| 3.0.4 | On demand | Download | 5d6eb130…b5b5f3 |
| 3.0.5 | On demand | Download | 65d94623…b39e50 |
| 3.0.6 | On demand | Download | 717eb042…b7bb83 |
| 3.1.0 | On demand | Download | 40c2a6a0…7269b6 |
| 3.1.1 | Cached · Upstream SHA-256 matched | Download | 66257a31…850214 |
Dependencies
flutter {
"sdk": "flutter"
}
flutter_web_plugins {
"sdk": "flutter"
}
image_picker_platform_interface "^2.11.0"
mime "\u003e=1.0.4 \u003c3.0.0"
web "\u003e=0.5.1 \u003c2.0.0"