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
- Get the package using your IDE's GUI or via command line with
$ pub get
- Import the
widgets_to_image.dart
file in your app
import 'package:convert_widget_to_image/widget_to_image.dart';
Usage
- First wrap you widget in a
RepaintBoundary()
and give him aGobalKey()
RepaintBoundary(
key: key,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12))),
onPressed: () {},
child: Text('Simple Button'),
),
)
- 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);
Additional information
Feel free to do pull requests or ask for changes on issues(on gitHub). There is a simple example on the github.