Search code examples
fluttersyncfusionpdf-viewerrebuild

PDF view widget constant rebuild during view


I am using syncfusion PDFviewer in a simple app to display a PDF from a URL using flutter. When I check the performance tap it shows the widget constantly rebuilding even though the page is fully loaded and I'm not interacting with the emulator. I'm not sure if this is supposed to be happening, but I don't see this for any other screen. Also occurs when accessing a PDF in assets or local file. Does this need a callback or setstate to stop the refresh? I know the words, but not the techniques.

Below is my code:

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';

void main() {
runApp(MyApp());}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
 return MaterialApp(
  title: 'SF PDFViewer Test',
  theme: ThemeData(
    primarySwatch: Colors.blue,
  ),
  home: MyHomePage(),
 );}}

 class MyHomePage extends StatefulWidget {
 @override
 _MyHomePageState createState() => _MyHomePageState();}

 class _MyHomePageState extends State<MyHomePage> {
 @override
 Widget build(BuildContext context) {
 return Scaffold(
   appBar: AppBar(
     title: Text('SF PDF Viewer Example'),),
  body: Center(),
  floatingActionButton: FloatingActionButton(
    onPressed: () => Navigator.push(
        context, MaterialPageRoute(builder: (context) => PdfViewerApp())),
    tooltip: 'View PDF',
    child: Icon(Icons.document_scanner_rounded),
  ),);}}

 class PdfViewerApp extends StatelessWidget {
 const PdfViewerApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
 return SafeArea(
   child: Scaffold(
     appBar: AppBar(
       title: Text('SF PDFViewer'),
    ),
    body:
      Container(
        child: 
   SfPdfViewer.network('http://www.pdf995.com/samples/pdf.pdf'),
      ),),);}}

Here is my flutter doctor

 Doctor summary (to see all details, run flutter doctor -v):
 [✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-arm, locale en-US)
 [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ✗ Android license status unknown.
    Run `flutter doctor --android-licenses` to accept the SDK licenses.
    See https://flutter.dev/docs/get-started/install/macos#android-setup for more 
    details.
  [✓] Xcode - develop for iOS and macOS
  [✓] Chrome - develop for the web
  [✓] Android Studio (version 4.2)
  [✓] Connected device (3 available)

  ! Doctor found issues in 1 category.

Solution

  • We confirmed that the issue with "SfPdfViewer rebuilds continuously without any user interactions" is a defect. The issue fix will be included in our July 3rd weekly package release which is estimated to be available on 20 July 2021 tentatively.

    The status of this issue can be tracked using following link. https://www.syncfusion.com/feedback/26815/sfpdfviewer-rebuilds-continuously-without-any-user-interactions