Layout ERROR when using COLUMN layout

Hello,

If I have a screen and want the body to contain 2 children (e.g. a breadcrumb, followed by your SfPdfViewer then, I get a hasSize error (please see the attachment). On the other hand, if I set your SfPdfViewer widget as the body then it all works fine (but I need breadcrumb in my case)

below is pseudo code for issue:


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(AppLocalizations.of(context)?.sample_text??
            common.sample_test),
        titleSpacing: 0,
        elevation: 0, // appbar shadow off
      ),
      body: Column(children: <Widget>[
        breadCrumbBar(context, _crumbs), // My widget breadCrumbs
// I tried using sizeBox to limit height and that works but not ideal
      SizedBox(
// If i set a height then it works but the pdf height is wrong depending
// on the device
        //  height: MediaQuery.of(context).size.height - 240,

          child: SfPdfViewer.network(
            headers: {
              'Authorization': 'Bearer $_jwt',
            },
            interactionMode: PdfInteractionMode.pan,
            _folder.listOfItems[_posterIndex].uri,
            controller: _pdfViewerController,
            key: _pdfViewerKey,
          ), //net
        ), // sizeBox
      ]), // children + column
    ); // Scaffold
  } //

Any help will be greatl

Attachment: hasSizeErr_c2562f53.zip

2 Replies 1 reply marked as answer

DR Deepika Ravi Syncfusion Team April 21, 2022 02:49 PM UTC

Hi enrique benedetti,


To resolve the issue when adding the SfPdfViewer widget to the column widget, kindly refer to the following code snippet.


 

@override

Widget build(BuildContext context) {

  return Scaffold(

    appBar: AppBar(

      title: const Text('Syncfusion Flutter PDF Viewer'),

    ),

    body: Column(

      children: [

        Container(

          height: 200,

          color: Colors.pink,

        ),

        Expanded(

          child: SfPdfViewer.network(

            'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf',

            key: _pdfViewerKey,

          ),

        ),

      ],

    ),

  );

}



Kindly try this and revert us if you have any concerns.


Regards,

Deepika Ravi


Marked as answer

EB enrique benedetti April 21, 2022 06:18 PM UTC

Hello,

I made the suggested changes and the page/program no longer crashes.

Thanks for your prompt response.


Thanks again,

Enrique


Loader.
Up arrow icon