image_painter 1.0.0-nullsafety.0 copy "image_painter: ^1.0.0-nullsafety.0" to clipboard
image_painter: ^1.0.0-nullsafety.0 copied to clipboard

A flutter package for drawing over images. Supports color, strokeWidth, different paintModes and exporting image.

image_painter #

pub package Platform Badge style: effective dart License: MIT

A flutter implementation of painting over image.

Overview #

demo!

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.

[Note] Tested and working only on flutter stable channel. Please make sure you are on stable channel of flutter before using the package.

Getting started #

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  image_painter: latest

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 #

Check out the example

Basic usage of the libary:

  • ImagePainter.network: Painting over image from network url.
///Initialize the controller
Controller imageController = Controller();
GlobalKey<ImagePainterState> _imageKey = GlobalKey<ImagePainterState>();
///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 = imageController.copyWith(color:Colors.red);
    imageController = imageController.copyWith(mode:PaintMode.Arrow);
    imageController = imageController.copyWith(strokeWidth:10.0);
})
///Export the image:
Uint8List image = await _imageKey.currentState.exportImage();
///Now you use [Uint8List] data and convert it to file.
File imgFile = new File('directory/sample.png');
    imgFile.writeAsBytesSync(image);

For more thorough implementation guide check the example

177
likes
130
pub points
94%
popularity

Publisher

unverified uploader

A flutter package for drawing over images. Supports color, strokeWidth, different paintModes and exporting image.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, vector_math

More

Packages that depend on image_painter