Code Monkey home page Code Monkey logo

Comments (6)

ritheshSalyan avatar ritheshSalyan commented on July 21, 2024 1

Currently Screenshot support capturing of non rendered elements. You can make use of captureFromWidget function like shown below

  screenshotController
                    .captureFromWidget(Container(
                        padding: const EdgeInsets.all(30.0),
                        decoration: BoxDecoration(
                          border:
                              Border.all(color: Colors.blueAccent, width: 5.0),
                          color: Colors.redAccent,
                        ),
                        child: Text("This is an invisible widget")))
                    .then((capturedImage) {
                  ShowCapturedWidget(context, capturedImage);
                });

from screenshot.

vedantrathore avatar vedantrathore commented on July 21, 2024

Any update ?

from screenshot.

Sammius avatar Sammius commented on July 21, 2024

It would be very helpful for me too!

from screenshot.

bdlukaa avatar bdlukaa commented on July 21, 2024

It's not possible because this package uses a RepaintBoundary under the hood, so that means it can only take screenshot of the widgets that are rendered. What you can do is add the widgets to the screen, take a screenshot, and then remove them:

setState(() => widgetsVisible = true);
await takeScreenshot();
setState(() => widgetsVisible = false);

You can use something like overlay or dialog to hide the screen while the screenshot is happening!

from screenshot.

Sammius avatar Sammius commented on July 21, 2024

I am currently using the functions from here. It also uses RepaintBoundary, but no real repaints are required. Maybe something similar can be applied here.

from screenshot.

daybson avatar daybson commented on July 21, 2024

Currently Screenshot support capturing of non rendered elements. You can make use of captureFromWidget function like shown below

  screenshotController
                    .captureFromWidget(Container(
                        padding: const EdgeInsets.all(30.0),
                        decoration: BoxDecoration(
                          border:
                              Border.all(color: Colors.blueAccent, width: 5.0),
                          color: Colors.redAccent,
                        ),
                        child: Text("This is an invisible widget")))
                    .then((capturedImage) {
                  ShowCapturedWidget(context, capturedImage);
                });

How do I trigger the captureFromWidget from a method, if the wifget to be captured is the Scaffold? There's my Listview with some elements outside view, and I want them on the screen shot too.

@override
  Widget build(BuildContext context) {
    b = build2(context);
    return b;
  }

void printScreen() async {
    screenshotController
        .captureFromWidget(Container(
            padding: const EdgeInsets.all(30.0),
            decoration: BoxDecoration(
              border: Border.all(color: Colors.blueAccent, width: 5.0),
              color: Colors.redAccent,
            ),
            child: b))
        .then((image) async {
      final directory = (await getTemporaryDirectory()).path;
      File imgFile =
          new File('$directory/${controller.ficha.value.nome}_screenshot.png');
      await imgFile.writeAsBytes(image);
      Share.shareFiles(['${imgFile.path}'],
          text: 'Personagem ${controller.ficha.value.nome}');
    });
}

from screenshot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.