[image_picker] Update Android example (#4504)

Updates the Android implementation package's example app to use the latest version of the platform interface APIs, in preparation for formally deprecating the older versions.
This commit is contained in:
stuartmorgan
2023-07-18 14:00:06 -07:00
committed by GitHub
parent 5af829020c
commit af584ff7b5
3 changed files with 23 additions and 16 deletions

View File

@ -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.

View File

@ -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(() {
@ -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]);

View File

@ -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"