convert_widget_to_image

Creator: coderz1093

Last updated:

Add to Cart

Description:

convert widget to image

A simple package who convert widgets to image types;
Features #
Types Supported:

Uint8List
ByteData
Image
Dart:ui Image

Getting started #

Add this to your package's pubspec.yaml file:

dependencies:
widget_to_image: any
copied to clipboard

Get the package using your IDE's GUI or via command line with

$ pub get
copied to clipboard

Import the widgets_to_image.dart file in your app

import 'package:convert_widget_to_image/widget_to_image.dart';
copied to clipboard
Usage #

First wrap you widget in a RepaintBoundary() and give him a GobalKey()

RepaintBoundary(
key: key,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12))),
onPressed: () {},
child: Text('Simple Button'),
),
)
copied to clipboard

Then pass the key to the WidgetToImage selecting the constructor of type that you want

final dartUiImage = await WidgetToImage.asDartUiImage(key);
final byte = await WidgetToImage.asByteData(key);
final uint = await WidgetToImage.asUint8List(key);
final image = await WidgetToImage.asImage(key);
copied to clipboard
Additional information #
Feel free to do pull requests or ask for changes on issues(on gitHub). There is a simple example on the github.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.