首页 > 解决方案 > Flutter multi_image_picker 相机选项未在 iOS 中显示。当我已经启用相机并在 info.plist 中写入权限时

问题描述

它显示了唯一的最近图片。我也想要一个相机选项。这是我的代码。

  Future<void> loadAssets(StateSetter setModalState) async {
    print("On pressed");
    List<Asset> resultList = List<Asset>();
    String error = 'No Error Dectected';

    try {
      resultList = await MultiImagePicker.pickImages(
        maxImages: 2,
        enableCamera: true,
        selectedAssets: image,
        materialOptions: MaterialOptions(
          actionBarColor: "#abcdef",
          actionBarTitle: "Example App",
          allViewTitle: "All Photos",
          useDetailsView: false,
          selectCircleStrokeColor: "#000000",
        ),
      );
    } on Exception catch (e) {
      error = e.toString();
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setModalState(() {
      image = resultList;
      print("Set state");
      if(image.length>0){
        showUploadButton = false;
      }else{
        showUploadButton = true;
      }

     // _error = error;
      //print(_error);
    });
  }

我不知道为什么会这样。我已经删除了应用程序并重新安装。并且还清理了 android studio。但它仍然只显示最近的图片

标签: androidiosflutterdartimagepicker

解决方案


写在 info.plist

    <key>NSPhotoLibraryUsageDescription</key>
    <string>This app requires access to the photo library.</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>This app does not require access to the microphone.</string>
    <key>NSCameraUsageDescription</key>
    <string>This app requires access to the camera.</string>

在此处输入图像描述


推荐阅读