Wednesday, November 30, 2022
HomeiOS Developmentflutter - no such file or listing when i attempt to add...

flutter – no such file or listing when i attempt to add file on ios


i attempt to decide audio file on ios gadget, and when add file with the DIO i acquired no such file or director. I decide file with then file_picker. After that i attempted to repeat file (if present gadget is ios) to getApplicationDocumentsDirectory, however acquired this message on copy proccess

`

 void selectAudio() async {
    last FilePickerResult? consequence = await FilePicker.platform.pickFiles(
      sort: FileType.audio,
      allowMultiple: true,
    );
    if (consequence == null) return;
    if (fileList.size + consequence.information.size > 6) {
      Get.showErrorMessage(
        'txt_oops'.tr,
        'txt_max_amount_of_selected_files'.tr,
      );
      return;
    }
    for (PlatformFile file in consequence.information) {
      fileList.add(
        FileModel(null)..localfile = file.path,
      );
    }
  }

  Future<void> uploadFile(FileModel file, String mimeType) async {
    File localFile = File(file.localfile!);

    if (Platform.isIOS) {
      String documentPath = (await getApplicationDocumentsDirectory()).path;

      localFile = await localFile.copy(
        '$documentPath/${basename(localFile.path)}',
      );
    }

………

Future<FileModel?> uploadFile({
    required int profileId,
    required File file,
    void Perform(int present, int whole, int p.c)? onSendProgress,
  }) {
    return uploadFileToServer(
      url: "profile/$profileId/file/",
      onSendProgress: onSendProgress == null
          ? null
          : (int present, int whole) {
              int p.c = (present / whole * 100).toInt();
              onSendProgress(present, whole, p.c);
            },
      formData: dio.FormData.fromMap({
        "file": dio.MultipartFile.fromFileSync(
          file.path,
          filename: basename(file.path),
        ),
      }),
    );
  }
    

`

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments