capture_box 1.0.0 copy "capture_box: ^1.0.0" to clipboard
capture_box: ^1.0.0 copied to clipboard

A Flutter package that turns your custom widgets into an image file.

CaptureBox #

CaptureBox is a package that turns your custom widgets into an image or a document file. It does this by wrapping your custom widget with a RepaintBoundary and converting the bytelist obtained from its rendering into centain file types (currently PNG, JPG and PDF).

You can either take the in-memory binary data for further usages or save them to a local directory by using the methods that start with "save".

When it comes to PDFs, it's possible to make the rendered content available for printing. You can do that by calling "printPdf" method.

Setup #

CaptureBox is on Pub. You can use it in your project by adding it to your pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter
  capture_box: ^1.0.0
copied to clipboard

Then, you install the plugin by executing the following command from inside your project directory:

flutter pub get
copied to clipboard

Examples #

Let's say you want to generate a PNG image file from a red Container with a text saying "Example" in the middle. In order to to that, you need to import the capture_box library first:

import 'package:capture_box/capture_box.dart';
copied to clipboard

Then, you need to declare a new CaptureBoxController:

final CaptureBoxController controller = CaptureBoxController();
copied to clipboard

After that, you can wrap a Container with a CaptureBox like such:

...
CaptureBox(
    controller: controller, 
    child: Container(
        color: Colors.red,
        child: const Text("Example"),
    )
),
...
copied to clipboard

Finally, you can execute the following method to generate the image file and save it to a user-defined directory:

controller.trySavePng(
    fileName: "example",
    onError: () => print("failed")
);
copied to clipboard

Support for Apple Devices #

Currently, there's no forecast for adding support to IOS ans MacOS platforms. There's no way to assure that the library's resources will work on Apple devices when the core developer of this package doesn't have access to these techlonogies for the purpose of testing.

Apple devices tend to be quite expensive, especially on countries under development. If you'd like to see this project having support for IOS and MacOS platforms, consider sponsoring this project. Check the Sponsor button at the top of this repository's page to see how.

Support the Project #

Contributing #

This project is being maintained by a sole developer. For now, there are no resources available to keep a frequent development and code review routine to guarantee that the code pulled by other developers won't compromise the library's principles.

Despite that, you can help this project by giving a donation. That way, this one-person DevTeam can dedicate its time and effort to collaborate with the community by developing free and open-source software.

Donating #

If this package has helped adding value to your software or if you appreciated the initiative, consider giving a donation to help this project keep being maintained and improved.

When submitting a donation, you can leave a comment telling us how this package has helped you and what could be done to make it even better. That would be much appreciated.

  • PayPal
    paypal
  • Buy me a Coffee
    "Buy Me A Coffee"

...

3
likes
140
points
55
downloads

Publisher

verified publishercaribesphaneron.com

Weekly Downloads

2024.09.21 - 2025.04.05

A Flutter package that turns your custom widgets into an image file.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

file_picker, flutter, flutter_web_plugins, image, path, path_provider, pdf, plugin_platform_interface, printing, universal_html

More

Packages that depend on capture_box