Questions tagged [custom-painting]
147 questions
19
votes
4 answers
Flutter: How to paint an Icon on Canvas?
I'm using a CustomPainter to draw in Flutter like this:
@override
void paint(Canvas canvas, Size size) {
canvas.drawRect(...);
canvas.drawImage(...);
...
}
How to draw an Icon on canvas?

IronHawk
- 365
- 3
- 7
9
votes
2 answers
How to implement eraser feature for flutter drawing app
There is a video about creating a drawing app by flutter (YouTube) which support to draw lines / points when user tapping on screen but I can't find a feature / way to erase what user had drawn like Android native (like here) especially for lines. I…

Anson Woo
- 91
- 4
9
votes
2 answers
Why is drawing on JFrame so much slower than on a JPanel?
My question is WHY is the same swing-custom-painting routine nearly 16 times faster when drawing on a JPanel compared to directly on the JFrame? Is it just double-buffering? It can't be, surely?
Background: I had a problem with the custom-painting…

corlettk
- 13,288
- 7
- 38
- 52
8
votes
2 answers
Flutter : Custom Painter draw path with different fill and stroke color
I am using the CustomPainter to draw a line chart where the line(stroke) needs to be of a different color and the fill color should be a different shade of it.
I could draw the chart but both with same colors.
However, I need the colors to be…

Akash Gorai
- 580
- 1
- 8
- 17
8
votes
1 answer
Flutter drawing a heart shape with CustomPainter
I'm wondering if anyone has any pointers on how to get started on drawing a heart shape in flutter with CustomPainter. I've managed to draw things like triangles and squares, or a basic circle, but a heart of course has both straight and curved…

Hasen
- 11,710
- 23
- 77
- 135
8
votes
3 answers
Flutter CustomPaint shadow
I have the following widget:
class OutsiderButton extends StatelessWidget {
final Function onPressed;
final Icon icon;
final OutsiderButtonPosition position;
OutsiderButton({this.onPressed, @required this.icon, this.position});
…

Andre Haueisen
- 468
- 2
- 8
- 20
7
votes
6 answers
How do I get to tap on a CustomPaint path in Flutter using GestureDetect?
I'm very new to flutter and am trying to figure out how to get a gesture detected on a CustomPaint path. I can click on a host of other things but not on paths for some reason... How do I get this to work? My code thus far is below.
import…

graciax452
- 71
- 1
- 4
6
votes
2 answers
flutter CustomPainter - how to cut out a hole in line path
I have a CustomPaint which paints an oval.
I want to cut out a hole at a specific position which I couldn't figure out yet how that works.
I tried:
canvas.drawPath(
Path.combine(PathOperation.difference, ovalPath, holePath),
ovalPaint,
…

tmaihoff
- 2,867
- 1
- 18
- 40
6
votes
1 answer
Flutter Improve CustomPainter animation performance
I needed a loading widget that draws the moving sine and cosine functions into a canvas. I coded it with no problem using a CustomPaint widget and a CustomPainter, but when I profile it, i Have discovered it runs on about 49fps, and not on 60fps.…

Javierd98
- 708
- 9
- 27
6
votes
1 answer
Flutter editable text on canvas
I am trying to add an editable textbox to the canvas in Flutter, that will bring up the keyboard once selected.
I am using a custom painter to print text to a canvas (shown in the code below). Is it possible to make this text editable, or add a text…

samdangerous
- 73
- 1
- 5
5
votes
1 answer
Flutter canvas, how to paint over the child widget?
I am trying to draw red dots over the child textbox widget like this:
For that, I wrapped the child widget with CustomPaint() widget:
return CustomPaint(
painter: DotsPainter(), //draws red dots based on child's size
child: child,…

Nick
- 455
- 9
- 28
5
votes
1 answer
How to get an image from a canvas drawn with CustomPainter?
In my Flutter app I use a CustomPainter to allow a user to draw their signature on the screen. I need to find a way to save this as an image.
PictureRecorder works nicely when you are able to pass the PictureRecorder object to the canvas as per…

alichur
- 925
- 7
- 19
4
votes
1 answer
Flutter - How to move and zoom Canvas drawings without AGAIN running something like the CustomPainter paint method?
I have tried using the methods "Transform.scale" (for "zooming" ) and "Transform.translate" (for the moving), but they seem to trigger the paint method in the CustomPainter.
(even though the method "shouldRepaint" returns false, but that method is…

user743436
- 324
- 2
- 14
4
votes
1 answer
Java: Pacman collision detection with wall
I have been trying my best to work out collision detection between Pacman and the walls, however my implementation doesn't seem to work as correctly
Does collision detection work at all? Yes
Does it behave correctly? No
How is it currently…

tommy knocker
- 371
- 1
- 7
- 19
4
votes
1 answer
Flutter Custom paint cross with path but with gradient and rounded corners
I've just started getting to grips with Custom painter and I've created a basic cross but not sure how to make the corners rounded and make the colour a gradient?
It seems a gradient requires createShader which takes a rect but I don't have one…

Hasen
- 11,710
- 23
- 77
- 135