簡體   English   中英

ios 上的 flutter 下載器和路徑提供程序

[英]flutter downloader and path provider on ios

我已經設法使 flutter 下載器和路徑提供程序在 android 上工作,但它在 ios 上不起作用,說這是一個 ZC31B32364CE1ECCECEAFCD 這是代碼:

 secondaryActions: <Widget>[
        IconSlideAction(
          caption: 'Download',
          color: Colors.green,
          icon: Icons.arrow_circle_down,
          onTap: () async {
            final status = await Permission.storage.request();
            if (status.isGranted) {
              final externalDir = await getExternalStorageDirectory();
              final id = await FlutterDownloader.enqueue(
                  url: f.url,
                  savedDir: externalDir.path,
                  showNotification: true,
                  openFileFromNotification: true);
            } else {
              toast('Permission Denied');
            }
          },
        ),

對於 iOS,在獲得許可后,您應該使用final externalDir = await getApplicationDocumentsDirectory() ,因為getExternalStorageDirectory()

您可以進行操作系統檢查:

var externalDir;
if (Platform.isIOS) { // Platform is imported from 'dart:io' package
  externalDir = await getApplicationDocumentsDirectory();
} else if (Platform.isAndroid) {
  externalDir = await getExternalStorageDirectory();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM