Code Monkey home page Code Monkey logo

Comments (5)

nhien021299 avatar nhien021299 commented on July 21, 2024 3

Try this man, it work for me:

await _screenshotController.capture(delay: const Duration(milliseconds: 10)).then((Uint8List image) async {
      if (image != null) {
        final directory = await getApplicationDocumentsDirectory();
        final imagePath = await File('${directory.path}/image.png').create();
        final Uint8List pngBytes = image.buffer.asUint8List();
        await imagePath.writeAsBytes(pngBytes);
        await Share.shareFiles([imagePath.path]);
      }
    });

from screenshot.

 avatar commented on July 21, 2024 1

This should be added to the package documentation :)

from screenshot.

jxstxn1 avatar jxstxn1 commented on July 21, 2024

Watch out the dart:convert package and the DataType File

You can also try this line of code:
File.fromRawPath(Uint8List uint8List);

from screenshot.

jxstxn1 avatar jxstxn1 commented on July 21, 2024

Try this man, it work for me:
await _screenshotController.capture(delay: const Duration(milliseconds: 10)).then((Uint8List image) async {
if (image != null) {
final directory = await getApplicationDocumentsDirectory();
final imagePath = await File('${directory.path}/image.png').create();
final Uint8List pngBytes = image.buffer.asUint8List();
await imagePath.writeAsBytes(pngBytes);
await Share.shareFiles([imagePath.path]);
}
});

I recommend a non-static filename, because the static one can create issues.
Generate a filename with a function like this:
String fileName = DateTime.now().microsecondsSinceEpoch.toString();
With this you have a non-static filename.
Now assign it at the save point:
final imagePath = await File('${directory.path}/$fileName.png').create();

from screenshot.

stephanie-finch avatar stephanie-finch commented on July 21, 2024

I recommend a non-static filename, because the static one can create issues.

What types of issues happen when you use static filenames?

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.