NoSuchMethodError:在null上调用了获取方法“路径”。接收方:null尝试调用:路径

时间:2020-07-12 06:57:39

标签: android ios flutter dart flutter-layout

当我将pdf URL值传递给它时,它会因内置关键字“ path”而出现错误,并且似乎为空?

loadPdf(String pdfPath) async {
setState(() => _isLoading = true);

var fileName = pdfPath.split('/').last;

var localFileUrl = (await Directory(CacheManager.getInstance().appDocumentDir.path +'/'+"realpro"+"/").create(recursive: true)).path +fileName;

if (await CacheManager.getInstance().checkFileExist(localFileUrl)) {
  document = await PDFDocument.fromAsset(localFileUrl);
  print(document);
  setState(() {
    _isLoading = false;
  });
} else {
  document = await PDFDocument.fromURL(pdfPath);
  print(document);
  setState(() {
    _isLoading = false;
  });
}

}

0 个答案:

没有答案