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

[2.8.0 pdfx] Exception: Unknow error when loading on web

Open FelixUngerhoferAS opened this issue 1 year ago • 1 comments

Describe the bug When I run the web app, it first shows the DocumentLoaderBuilder (Progress Indicator), but then an unknown error occurs after loading and it doesn't show the pdf. I'm running the web app on a Mac. On my colleague's Linux, it works, and it also works when deploying it using Docker.

To Reproduce This is our code: Data is a pdf file that has to be retrieved. The same error also occurs when using openAsset with a stored pdf file.

Future<void> showFileDialog(BuildContext context, FutureOr<Uint8List> data, String displayName) async {

    final pdfPinchController = PdfControllerPinch(
      document: PdfDocument.openData(data),
    );

    return showDialog<void>(
      context: context,
      barrierDismissible: true,
      builder: (BuildContext context) {
        return StatefulBuilder(
          builder: (context, setState) {

            return AlertDialog(
              title: Row(
                children: [
                  Expanded(
                      child: Text(
                        displayName,
                        style: const TextStyle(fontWeight: FontWeight.bold),
                        textScaler: const TextScaler.linear(0.7),
                      )
                  ),

                  IconButton(
                      onPressed: (){
                        Navigator.of(context).pop();
                      },
                      icon: const Icon(Icons.close_rounded)
                  ),
                ],
              ),
              content: SizedBox(
                width: MediaQuery.of(context).size.height * 0.7,
                height: MediaQuery.of(context).size.height * 0.8,
                child:
                PdfViewPinch(
                  controller: pdfPinchController,
                  builders: PdfViewPinchBuilders<DefaultBuilderOptions>(
                    options: const DefaultBuilderOptions(),
                    documentLoaderBuilder: (_) =>
                      const Center(child: CircularProgressIndicator()),
                    pageLoaderBuilder: (_) =>
                      const Center(child: CircularProgressIndicator()),
                    errorBuilder: (_, error) {
                      return Center(child: Text(error.toString()));
                    },
                  ),
                ),
              ),
            );
          },
        );
      },
    );
  }

Expected behavior An error occurs after loading.

FelixUngerhoferAS avatar Sep 27 '24 10:09 FelixUngerhoferAS

Same here. Narrowed it down to Safari browser version 16.x

0xPr0xy avatar Apr 24 '25 16:04 0xPr0xy