Flutter:未处理的异常:无法加载资产

时间:2020-01-18 02:07:40

标签: flutter dart load assets

我正在尝试构建一个按钮应该打开pdf的应用程序。我在以下链接中使用了该指南:https://pspdfkit.com/blog/2019/opening-a-pdf-in-flutter/,但该应用程序在首次运行时将无法运行,只有在热重载/重启后才能运行。我试着拍打干净。 pubspec.yaml的输出也是退出代码0

@RequestMapping(value = "/groupid/get/{dbindex}/{dc}", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public Object getGroupId(@PathVariable Integer dbindex, @PathVariable Object dc) {

        service.setDB(dbindex);
        if (service.get("groupid", dc) == null) {
            BigInteger groupid = new BigInteger("1");
            service.set("groupid", dc, groupid);
            return service.get("groupid", dc);
        } else {
            BigInteger groupid = new BigInteger(String.valueOf(service.get("groupid", dc)));

            BigInteger updated = groupid.add(new BigInteger("1"));

            service.set("groupid", dc, updated);
            return service.get("groupid", dc);
        }
    }

以下是代码段:

flutter:
  assets:
    - PDFs/MyDoc.pdf
    - assets/

谢谢。

1 个答案:

答案 0 :(得分:0)

FadyCard是StateFull Widget,您需要在setState内更新PDF。 尝试这样(未经测试)

onPressed: () => {
              setState(() {
                prepareTestPdf().then((path) {
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                        builder: (context) => FullPdfViewerScreen(path)),
                  );
                })
              })
            }