flutter_pdf_render icon indicating copy to clipboard operation
flutter_pdf_render copied to clipboard

Feature request: ability to set scroll physics

Open ricardoboss opened this issue 3 years ago • 4 comments
trafficstars

I briefly looked at the code and to achieve setting scroll physics, a major rewrite would be required. You are currently using InteractiveViewer, which doesn't have a physics property or the concept of scrolling (just panning, which is scrolling in all directions, basically).

My experience with Dart and Flutter are limited, but I think the InteractiveViewer would need to be replaced with something like a ListView, which does support just setting physics.

Let me know what you think.

ricardoboss avatar May 23 '22 10:05 ricardoboss

Basically, InteractiveViewer is vital to support zooming feature and it takes considerable (I don't know actually) time to implement physics with it.

But, for your purpose, you can simply use List.builder; the following fragment is from Multi-page view using ListView.builder:

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Pdf_render example app'),
        ),
        backgroundColor: Colors.grey,
        body: Center(
          child: PdfDocumentLoader.openAsset(
            'assets/hello.pdf',
            documentBuilder: (context, pdfDocument, pageCount) => LayoutBuilder(
              builder: (context, constraints) => ListView.builder(
                itemCount: pageCount,
                itemBuilder: (context, index) => Container(
                  margin: EdgeInsets.all(margin),
                  padding: EdgeInsets.all(padding),
                  color: Colors.black12,
                  child: PdfPageView(
                    pdfDocument: pdfDocument,
                    pageNumber: index + 1,
                  )
                )
              )
            ),
          )
        )
      ),
    );
  }

espresso3389 avatar May 23 '22 11:05 espresso3389

That let's me achieve the scroll physics I want, but it disables zooming in. I tried re-adding it using InteractiveViewer, but as I said, I'm not an experienced Flutter dev, so I was not able to get it to work... Any idea?

ricardoboss avatar May 23 '22 16:05 ricardoboss

@ricardoboss It's not so easy task for any developer to implement such mechanism to InteractiveViewer :(

espresso3389 avatar May 23 '22 16:05 espresso3389