packages.flutter icon indicating copy to clipboard operation
packages.flutter copied to clipboard

After changing the state or rebuilding the widget, the PDF is not displayed. To Reproduce : keep one checkbox below the pdf so after changing the state of checkbox the pdf section keeps on loading and not able to see the pdf.

Open SanketJagtap1997 opened this issue 1 year ago • 5 comments

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. keep one checkbox below the pdf 2)change the state of checkbox using the setState
  2. the pdf section keeps on loading and not able to see the pdf.

Expected behavior After the rebuilding the widget also the pdf should display.

Additional context I have the used the decoded base64 string like this : PdfViewPinch( builders: PdfViewPinchBuilders<DefaultBuilderOptions>( options: const DefaultBuilderOptions(), documentLoaderBuilder: () => const Center(child: CircularProgressIndicator()), pageLoaderBuilder: () => const Center(child: CircularProgressIndicator()), errorBuilder: (_, error) => Center(child: Text(error.toString())), ), controller: PdfControllerPinch(document: PdfDocument.openData(base64.decode(base64String), );

SanketJagtap1997 avatar Nov 23 '22 07:11 SanketJagtap1997

I got the same problem when moving from dark theme to light theme while viewing pdf document Here's how I reproduced the bug: https://user-images.githubusercontent.com/75757472/204158074-40420d65-9a6f-459f-b887-aab9a055bef6.mp4

mgcarofano avatar Nov 27 '22 20:11 mgcarofano

I got the same issue. In my case I am using provider package to manage my app state. Whenever I navigate out of the screen that contains the pdfview then I come back it won't reload it . It will just disply circular progress indicator (the loading transition widget).

yahya489 avatar Jan 13 '23 06:01 yahya489

Any progress on this issue? Or any workaround?

tologonkudaiberdiuulu avatar Feb 10 '23 11:02 tologonkudaiberdiuulu

Any updates? For me this happened after the upgrade to the latest version (master branch on GH) and flutter 3.16.5. This is kind of a bummer since there are not that many good pdf rendering libraries out there.

astubenbord avatar Jan 12 '24 21:01 astubenbord

I faced this problem when I used the setState(), the only way that's work for me is putting the controller implementation inside the initState, otherwise the controller was disposed when widget rebuild. ` late PdfControllerPinch pdfPinchController; @override void initState() {

super.initState();

if (widget.pdfData != null) {
  pdfPinchController =
      PdfControllerPinch(document: PdfDocument.openData(widget.pdfData!));
} else {
  pdfPinchController =
      PdfControllerPinch(document: PdfDocument.openAsset(widget.pdfPath!));
}

} ` I also tried to use AsyncValue.when from riverpod. If I did the implementation when received the data, it also rebuilt everything and caused the problem. Every time it reloads, the controller will recreate.

crystalleung926 avatar Feb 27 '24 03:02 crystalleung926