image_painter

Flutter 中用于在图片上绘制的实现。

image_painter_sample

特点

  • 七种可用的绘画模式。线条、框/矩形、圆形、自由/签名、虚线、箭头和文本。
  • 四种构造函数,用于从网络URL、资源图像、文件图像和内存中添加图像。
  • 来自构造函数的控件,如笔触宽度和颜色。
  • 将图像导出为内存字节,可转换为图像。 示例中提供了实现
  • 能够撤销和清除绘图。

[注意]
仅在Flutter稳定频道上测试并通过。在使用该包之前,请确保您使用的是Flutter的稳定频道。

入门

在您的 flutter 项目的 pubspec.yaml 文件中,添加以下依赖项

dependencies:
  ...
  image_painter: latest

在您的库中添加以下导入

import 'package:image_painter/image_painter.dart';

要开始使用 Flutter,请查看在线 文档

使用该库

查看示例

库的基本用法

  • ImagePainter.network:在网络URL上的图像上绘画。
final _imageKey = GlobalKey<ImagePainterState>();
//Provide controller to the painter.
ImagePainter.network("https://sample_image.png",
                  key: _imageKey,scalable: true),

///Export the image:
Uint8List byteArray = await _imageKey.currentState.exportImage();
//Now you use `Uint8List` data and convert it to file.
File imgFile = new File('directoryPath/fileName.png');
imgFile.writeAsBytesSync(image);

有关更全面的实现指南,请查看示例

GitHub

https://github.com/yellowQ-software/yellowQ-Flutter-Image-Painter