screenshot icon indicating copy to clipboard operation
screenshot copied to clipboard

Screenshot not coming fully

Open NiroopNife opened this issue 3 years ago • 6 comments

I'm having multiple tables which are introduced inside a SingleChildScrollView. I'm using the Screensot as the parent widget in the body of the Scaffold, but when i caputre the screenshot I'm just getting the image only which is visible to the user but not all the tables when scrolled down/up.


ScreenshotController screenshotController = ScreenshotController();

body: Screenshot(
        controller: screenshotController,
        child: TabBarView(
          children: [
            SingleChildScrollView(
              child: Padding(
                padding: EdgeInsets.only(bottom: 50.h.toDouble()),
                child: Column(children: v0),
              ),
            ),
            SingleChildScrollView(child: Column(children: v1)),
            SingleChildScrollView(child: Column(children: v2)),
            SingleChildScrollView(child: Column(children: v3)),
          ],
          controller: _tabController,
        ),
      ),

And the onPress function while capturing the screenshot

CaptureScreenshot() async {
    final uint8List = await screenshotController.capture();
    String tempPath = (await getTemporaryDirectory()).path;
    File file = File('$tempPath/image.png');
    await file.writeAsBytes(uint8List!);
    await Share.shareFiles([file.path]);
  }

And as i've went through other answers in issues found that the ScreenShot widget should be placed inside a SingleChildScrollView but if i use the SingleChildScrollView as the parent widget for the ScreenShot widget I'm getting an error as

RenderBox was not laid out: RenderRepaintBoundary#4b20b relayoutBoundary=up1 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1930 pos 12: 'hasSize'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.

NiroopNife avatar Jun 22 '21 10:06 NiroopNife

We have added a new method captureFromWidget. Can you try with this and see if it works?

SachinGanesh avatar Jun 22 '21 12:06 SachinGanesh

No even for that one too in the preview it was showing only of the content in the screen not of the whole page

NiroopNife avatar Jun 22 '21 12:06 NiroopNife

Any solution for this?

edinsonjohender avatar Aug 28 '21 14:08 edinsonjohender

Same here. @SachinGanesh help

daybson avatar Oct 17 '21 01:10 daybson

Did you solved @NiroopNife ? Is this package dead??

daybson avatar Nov 10 '21 10:11 daybson

So I am not sure about the real cause under the hood, but I had some SizedBox widgets for spacing and they caused the problem of the cutoff.

Remove them and you will see the whole view. You can replace them with padding widgets.

Another thing you can do is making the view longer, I know this seems wierd but it worked like a charm.

YazeedAlKhalaf avatar Jan 13 '22 12:01 YazeedAlKhalaf

You can provide a target size and set the desired resolution to capture screenshot.

Closing this issue. If you think it is incorrect, please reopen the issue

ritheshSalyan avatar Mar 15 '24 07:03 ritheshSalyan