Home > Software design >  how to scroll pdf in tabview with nestedScrollview - flutter
how to scroll pdf in tabview with nestedScrollview - flutter

Time:12-14

I'm using flutter_cached_pdfview can't scroll the pdf in tabview But scrollable without tabview Used controller but can't scroll in tabview

Want to scroll pdf in tabview with NestedScroolView

CodePudding user response:

Reference

Stack(
  children :[
    SfPdfViewer.asset(pdfAsset,
      controller: _pdfController,
    ),
    GestureDetector(
      onTap: (){
         setState(() {
           menuBarVisible = !menuBarVisible;
         });
      },
      child: Container()
    ),
  ]
),

CodePudding user response:

It sounds like you are trying to use a NestedScrollView inside a TabView to scroll through a PDF file displayed with the flutter_cached_pdfview package. However, you are encountering an issue where the PDF file cannot be scrolled when it is inside the TabView.

To resolve this issue, you can try wrapping the flutter_cached_pdfview widget inside a SingleChildScrollView instead of a NestedScrollView. The SingleChildScrollView widget is designed to scroll a single child widget, which is exactly what you need in this case.

Here is an example of how you might use the SingleChildScrollView widget to scroll the PDF file inside a TabView:

TabView(
  children: [
    SingleChildScrollView(
      child: PdfView(
        filePath: "path/to/pdf/file.pdf",
        controller: pdfController,
      ),
    ),
    // Other tabs...
  ],
),

Keep in mind that this is just an example, and you may need to adjust it based on the specific details of your app. For instance, you may need to adjust the filePath and controller properties of the PdfView widget based on how you are loading and controlling the PDF file in your app.

Additionally, you may need to add some padding or margin to the SingleChildScrollView widget to prevent the PDF file from being obscured by the TabBar. You can do this by using the padding or margin properties of the widget, or by wrapping the PdfView widget inside a Container and setting the padding or margin on the container.

  • Related