skip to Main Content

I am trying to put a PdfView and a close button inside a ListView. But it throws the following error

Exception caught by rendering library
The following assertion was thrown
during performLayout():
_PlatformViewPlaceholderBox object was given an infinite size during layout.

This probably means that it is a render object that tries to be as big
as possible, but it was put inside another render object that allows
its children to pick their own size.

Below is my code . I also tried giving it inside a Column under SingleChildScrollView. Still same error.

 ListView(children: [
              PDFView(
                filePath: pFile.path,
              ),
              Align(
                alignment: Alignment.topRight,
                child: IconButton(
                  onPressed: () {
                    Navigator.of(context).pop();
                  },
                  icon: const Icon(
                    Icons.close,
                    color: Colors.black,
                  ),
                ),
              ),
            ]),

What is missing here ? Can someone help ?

2

Answers


  1. Once wrap the list view with the sizedBox and assign a specific height and width, or else wrap the PDFView with the specific height and width it may work because the main issue is regarding the space that its not allotted to that particular widget so he cant take its own size

    Login or Signup to reply.
  2. Remove Listview and use Column with Expanded widget

    Column(
      children: [
        Expanded(
          child: PDFView(
            filePath: pFile.path,
          ),
        ),
        Align(
          alignment: Alignment.topRight,
          child: IconButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            icon: const Icon(
              Icons.close,
              color: Colors.black,
            ),
          ),
        ),
      ],
    )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search