capture_box 1.0.0 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
Then, you install the plugin by executing the following command from inside your project directory:
flutter pub get
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';
Then, you need to declare a new CaptureBoxController
:
final CaptureBoxController controller = CaptureBoxController();
After that, you can wrap a Container
with a CaptureBox
like such:
...
CaptureBox(
controller: controller,
child: Container(
color: Colors.red,
child: const Text("Example"),
)
),
...
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")
);
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.
...