image_gen 0.2.2
SDKdart
Platformwindowslinuxmacos
A tool to generate images from dart code.
Image Gen
A tool for generating images on your dart/flutter project.
Usage
- Run
dart pub add dev:image_gento add the plugin to your project. - Create a file to gen image.
- Add
import 'package:image_gen/image_gen.dart';to your file.(don't import other libraries) - Create a class that extends
ImageGeneratorand annotate it with@ImageGenannotation. (you can see example below) - Run
dart run build_runner buildto generate the image to your assets folder.
import 'package:image_gen/image_gen.dart';
@ImageGen()
class Abc extends ImageGenerator {
@override
GenImage generate() {
const width = 512;
const height = 512;
final rt = GenImage(width: width, height: height);
final layer = Layer(width: width, height: height);
// draw a rect
layer.draw(const Rect(
left: PercentQuantity(0),
right: PercentQuantity(0.5),
top: PercentQuantity(0),
bottom: PercentQuantity(0.5),
color: Uint8Color(),
roundCorner: 0.5,
));
rt.addLayer(layer);
return rt;
}
}
TODO
PR is well come, @normidar please.
- Draw circle feature
- Draw line feature
- Draw text feature