Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rxlabz/flutter_canvas_to_image
flutter example : canvas to png
https://github.com/rxlabz/flutter_canvas_to_image
canvas flutter image
Last synced: about 1 month ago
JSON representation
flutter example : canvas to png
- Host: GitHub
- URL: https://github.com/rxlabz/flutter_canvas_to_image
- Owner: rxlabz
- Created: 2018-04-09T19:09:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-01T20:22:19.000Z (over 5 years ago)
- Last Synced: 2024-05-01T22:51:53.392Z (8 months ago)
- Topics: canvas, flutter, image
- Language: Dart
- Size: 110 KB
- Stars: 107
- Watchers: 4
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# canvas_to_image
a simple Flutter canvas to png file example
![screen](screenshot.png)
```dart
final recorder = new ui.PictureRecorder();
final canvas = new Canvas(
recorder,
new Rect.fromPoints(
new Offset(0.0, 0.0), new Offset(200.0, 200.0)));final stroke = new Paint()
..color = Colors.grey
..style = PaintingStyle.stroke;canvas.drawRect(
new Rect.fromLTWH(0.0, 0.0, 200.0, 200.0), stroke);final paint = new Paint()
..color = color
..style = PaintingStyle.fill;canvas.drawCircle(
new Offset(
widget.rd.nextDouble() * 200.0,
widget.rd.nextDouble() * 200.0,
),
20.0,
paint);final picture = recorder.endRecording();
final img = picture.toImage(200, 200);
final pngBytes = await img.toByteData(format: new ui.EncodingFormat.png());
```In this example the image is displayed in a Image.memory widget
```dart
new Image.memory(new Uint8List.view(imgBytes.buffer));
```___
## Getting Started with Flutter
For help getting started with Flutter, view our online
[documentation](https://flutter.io/).