image_picker flutter -从图库中选取图像时,ios模拟器不显示图像

w7t8yxp5  于 2022-12-15  发布在  iOS
关注(0)|答案(1)|浏览(335)

我在flutter应用程序中使用image_picker 0.8.5包进行图像上传。
下面的代码在android模拟器中运行良好,但ios模拟器不显示图像。

List images = [[]];
  final _picker = ImagePicker();
  Future<void> _openImagePicker() async {
    final XFile? pickedImage =
        await _picker.pickImage(source: ImageSource.gallery);
    if (pickedImage != null) {
      setState(() {
        images[index].add(pickedImage);
      });
    }
  }

.......

Expanded(
              child: SingleChildScrollView(
                scrollDirection: Axis.horizontal,
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    PhotoCarouselWidget(
                      ImageList: images[subindex],
                      onRemove: (int) {
                        setState(() {
                          images[subindex].removeAt(int);
                        });
                      },
                    ),
                  ],
                ),
              ),
            ),

在ios模拟器控制台,我可以得到以下错误,当我点击图像拾取器按钮。

VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: PlatformException(multiple_request, Cancelled by a second request, null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:177:18)
<asynchronous suspension>
#2      MethodChannelImagePicker.getImage (package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:190:26)
<asynchronous suspension>
#3      _AddCounselStep1PageState._openImagePicker (package:laxia/views/pages/main/contribution/counsel_add_step1.dart:37:9)
<asynchronous suspension>

iOS模拟器是iPhone13(iOS15.4)。
请帮助我修复这个错误,在ios模拟器中显示图像。

bvhaajcl

bvhaajcl1#

图像拾取器不显示从iOS模拟器中拾取的图像。在image_picker页面的官方文档中提到了这一点。https://pub.dev/packages/image_picker#installation
从版本0.8.1开始,iOS实施使用PHPicker在iOS 14或更高版本上拾取(多个)图像。由于实施PHPicker,无法在iOS 14+中的iOS模拟器上拾取HEIC图像。这是一个已知问题。请在真实的设备上测试此问题,或使用非HEIC图像进行测试,直到Apple解决此问题。63426347 - Apple已知问题

相关问题