1

I am building a Flutter app that allows you to draw pixel art on a canvas using CustomPainter. My Paint() method looks like so:

final paint = Paint()
      ..color = Colors.deepPurple
      ..style = PaintingStyle.fill
      ..isAntiAlias = false
      ..strokeWidth = 1;

Which gives me something like this (zoomed in): App Canvas

After testing this I realized that that strokeWidth = 1 does not mean 1 pixel. I can change it to .1 or something, but that then seems to be doing sub-pixel painting. How can I get my stroke width to be exactly 1 pixel?

I looked through the documentation and I'm not understanding why this is happening.

Zach Russell
  • 1,060
  • 2
  • 13
  • 27

1 Answers1

3

you can use:

Paint paint = Paint() ..color = Colors.red ..strokeWidth = 2 ..style = PaintingStyle.stroke ..strokeJoin = StrokeJoin.round ;
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103