https://github.com/prongbang/snapshot_widget
A Flutter library to Snapshot Widget to Uint8List image.
https://github.com/prongbang/snapshot_widget
Last synced: 2 months ago
JSON representation
A Flutter library to Snapshot Widget to Uint8List image.
- Host: GitHub
- URL: https://github.com/prongbang/snapshot_widget
- Owner: prongbang
- License: mit
- Created: 2022-04-22T07:13:43.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-20T06:26:44.000Z (over 2 years ago)
- Last Synced: 2025-07-30T21:46:32.860Z (2 months ago)
- Language: Dart
- Homepage: https://pub.dev/packages/snapshot_widget
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# snapshot_widget
[](https://pub.dartlang.org/packages/snapshot_widget)
A Flutter library to Snapshot Widget to Uint8List image.
## Features
- Snapshot Widget
```dart
final _controller = SnapshotsController();SnapshotsWidget(
controller: _controller,
child: Container(),
)
```- Snapshot widget to Uint8List
```dart
final imageBytes = await _controller.value(pixelRatio: 16 / 9);
```## Getting started
It is really easy to use! You should ensure that you add the `snapshot_widget` as a dependency in your flutter project.
```yaml
snapshot_widget: "^1.0.1"
```## Usage
```dart
class _MyAppState extends State {
final _controller = SnapshotsController();
Uint8List _image = Uint8List.fromList([]);@override
Widget build(BuildContext context) {
return Column(
children: [
SnapshotsWidget(
controller: _controller,
child: const SmartCardWidget(),
),
OutlinedButton(
onPressed: _SnapshotsWidget,
child: const Text('Snapshot'),
),
const Divider(),
if (_image.isNotEmpty)
Image.memory(_image),
],
);
}void _SnapshotsWidget() async {
final imageBytes = await _controller.value(pixelRatio: 16 / 9);
setState(() {
_image = imageBytes;
});
}
}
```