Skip to content

[image_picker] Update Android example #4504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/image_picker/image_picker_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.7+4

* Updates the example to use the latest versions of the platform interface APIs.

## 0.8.7+3

* Bumps androidx.activity:activity from 1.7.1 to 1.7.2.
Expand Down
33 changes: 18 additions & 15 deletions packages/image_picker/image_picker_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,23 @@ class _MyHomePageState extends State<MyHomePage> {
await _displayPickImageDialog(context,
(double? maxWidth, double? maxHeight, int? quality) async {
try {
final List<XFile>? pickedFileList = isMedia
final ImageOptions imageOptions = ImageOptions(
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: quality,
);
final List<XFile> pickedFileList = isMedia
? await _picker.getMedia(
options: MediaOptions(
allowMultiple: isMultiImage,
imageOptions: ImageOptions(
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: quality,
)),
imageOptions: imageOptions),
)
: await _picker.getMultiImage(
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: quality,
: await _picker.getMultiImageWithOptions(
options: MultiImagePickerOptions(
imageOptions: imageOptions,
),
);
if (pickedFileList != null && context.mounted) {
if (pickedFileList.isNotEmpty && context.mounted) {
_showPickedSnackBar(context, pickedFileList);
}
setState(() {
Expand Down Expand Up @@ -167,11 +168,13 @@ class _MyHomePageState extends State<MyHomePage> {
await _displayPickImageDialog(context,
(double? maxWidth, double? maxHeight, int? quality) async {
try {
final XFile? pickedFile = await _picker.getImage(
final XFile? pickedFile = await _picker.getImageFromSource(
source: source,
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: quality,
options: ImagePickerOptions(
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: quality,
),
);
if (pickedFile != null && context.mounted) {
_showPickedSnackBar(context, <XFile>[pickedFile]);
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Android implementation of the image_picker plugin.
repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22

version: 0.8.7+3
version: 0.8.7+4

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down