# image_picker_for_web 3.1.1

Web platform implementation of image_picker




## Installing
```
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'image_picker_for_web:3.1.1'
```
Published: 2025-11-18T16:49:01.946551Z
Expected archive SHA-256: 66257a3191ab360d23a55c8241c91a6e329d31e94efa7be9cf7a212e65850214

Available in cache; verification: upstream_checksum
## Direct dependencies
- flutter: map[sdk:flutter]
- flutter_web_plugins: map[sdk:flutter]
- image_picker_platform_interface: ^2.11.0
- mime: >=1.0.4 <3.0.0
- web: >=0.5.1 <2.0.0

## Package README (untrusted upstream documentation)
# image\_picker\_for\_web

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

## 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](https://pub.dev/packages/cross_file).

### input file "accept"

In order to filter only video/image content, some browsers offer an [`accept` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept) in their `input type="file"` form elements:

![Data on support for the input-file-accept feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/input-file-accept.png)

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](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture):

![Data on support for the html-media-capture feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/html-media-capture.png)

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](https://caniuse.com/mdn-api_htmlinputelement_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`, `maxHeight` and `imageQuality` are not supported for `gif` images.
* `imageQuality` only affects `jpg` and `webp` images.

### `getVideo()`

The argument `maxDuration` is not supported on the web.

## Usage

### Import the package

This package is [endorsed](https://flutter.dev/to/endorsed-federated-plugin),
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:

<?code-excerpt "example/lib/readme_excerpts.dart (ImageFromPath)"?>
```dart
if (kIsWeb) {
  image = Image.network(pickedFile.path);
} else {
  image = Image.file(File(pickedFile.path));
}
```

Or, using bytes:

<?code-excerpt "example/lib/readme_excerpts.dart (ImageFromBytes)"?>
```dart
image = Image.memory(await pickedFile.readAsBytes());
```

[1]: https://pub.dev/packages/image_picker

## Changelog
## 3.1.1

* Uses `CanvasRenderingContext2D.drawImage` instead of the deprecated `drawImageScaled`.
* 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 `mime` package version constraint from `^1.0.4` to `>=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 `cancel` event on file selection. When the selection is canceled:
  * `Future<XFile?>` methods return `null`
  * `Future<List<XFile>>` methods return an empty list.

## 2.2.0

* Adds `getMedia` method.
* 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_identifiers` lint.

## 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`, `maxHeight` and `imageQuality` when selecting images
  (except for gifs).

## 2.1.3

* Add `implements` to pubspec.

## 2.1.2

* Updated installation instructions in README.

# 2.1.1

* Implemented `getMultiImage`.
* Initialized the following `XFile` attributes for picked files:
  * `name`, `length`, `mimeType` and `lastModified`.

# 2.1.0

* Implemented `getImage`, `getVideo` and `getFile` methods that return `XFile` instances.
* Move tests to `example` directory, so they run as integration_tests with `flutter 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 `android` directory.

# 0.1.0

* Initial open-source release.







 
