image_painter 0.1.1 image_painter: ^0.1.1 copied to clipboard
A flutter package for drawing over images. Supports color, strokeWidth, different paintModes and exporting image.
image_painter #
A flutter implementation of painting over image.
OverView #
Features #
- Seven available paint modes. Line, Box/Rectangle, Circle, Freestyle/Signature, Dotted Line, Arrow and Text.
- Four constructors for adding image from Network Url, Asset Image, Image from file and from memory.
- Controls from constructors like strokeWidth and Colors.
- Export image as memory bytes which can be converted to image. Implementation provided on example
- Ability to undo and clear drawings.
Getting started #
In the pubspec.yaml
of your flutter project, add the following dependency:
dependencies:
...
image_painter:
In your library add the following import:
import 'package:image_painter/image_painter.dart';
For help getting started with Flutter, view the online documentation.
Using the library #
Basic usage of the libary:
ImagePainter.network
: Painting over url from network.
///Initialize the controller
Controller imageController = Controller();
///Provide controller to the painter.
ImagePainter.network("https://sample_image.png",
key: _imageKey, controller: imageController, scalable: true),
///To change color, strokewidth or paint mode:
setState((){
imageController.color = Colors.red;
imageController.mode = PaintMode.Arrow;
imageController.strokeWidth = 10.0;
})
///Export the image:
Uint8List image = await _imageKey.currentState.exportImage();
///Now you use [Uint8List] image to convert it to file.
File imgFile = new File('myFilePath/sample.png');
imgFile.writeAsBytesSync(image);