ScerIO / packages.flutter

👨‍💻 Plugins and packages for Flutter framework
https://pub.dev/publishers/serge.software/packages
MIT License
461 stars 455 forks source link

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. #371

Open SanketJagtap1997 opened 1 year ago

SanketJagtap1997 commented 1 year ago

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 3) 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( 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), );

mgcarofano commented 1 year ago

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

yahya489 commented 1 year ago

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).

tologonkudaiberdiuulu commented 1 year ago

Any progress on this issue? Or any workaround?

astubenbord commented 10 months ago

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.

crystalleung926 commented 8 months ago

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.