我想在一个屏幕中创建pdf查看器和一个小部件

时间:2019-02-18 06:37:53

标签: flutter

我想创建一个飘动的屏幕,在屏幕的一半容纳一个PDF查看器,在后半部分设置一个小部件(文本图像等),我如何在一个屏幕上做到这一点

  @override
  void initState() {
    super.initState();
    createFileOfPdfUrl().then((f) {
      setState(() {
        pathPDF = f.path;
        print(pathPDF);
      });
    });
  }

  Future<File> createFileOfPdfUrl() async {
    final url = "http://africau.edu/images/default/sample.pdf";
    final filename = url.substring(url.lastIndexOf("/") + 1);
    var request = await HttpClient().getUrl(Uri.parse(url));
    var response = await request.close();
    var bytes = await consolidateHttpClientResponseBytes(response);
    String dir = (await getApplicationDocumentsDirectory()).path;
    File file = new File('$dir/$filename');
    await file.writeAsBytes(bytes);
    return file;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Plugin example app')),
      body: new Row(
        children: <Widget>[
          new Expanded(child:
          PDFViewerScaffold(
              path: pathPDF)),
          new FlutterLogo(size: 200.0,)
        ],
      )
    );
  }
}

我正在尝试以横向模式创建屏幕

0 个答案:

没有答案