Flutter

Custom Painting

CustomPaint, Canvas API, CustomPainter, drawing operations, performance, clipping

22 면접 질문·
Senior
1

Which widget should be used to draw custom graphics in Flutter?

답변

CustomPaint is the dedicated widget for custom drawing in Flutter. It takes a CustomPainter as a parameter containing the drawing logic via the paint() method. This widget creates a canvas where shapes, text, and images can be drawn with full control over every pixel.

2

What are the two mandatory methods to implement in a CustomPainter?

답변

A CustomPainter must implement paint() to define what is drawn on the Canvas, and shouldRepaint() to indicate whether the widget should be redrawn when the painter changes. shouldRepaint() returns a boolean and receives the old painter as a parameter to compare states.

3

What is the role of the Paint object in Flutter custom drawing?

답변

The Paint object defines the drawing style: color, stroke width, fill style (fill or stroke), line join type, shader effects, and filters. It acts as a configurable brush that determines the appearance of everything drawn on the Canvas.

4

What is the difference between PaintingStyle.fill and PaintingStyle.stroke?

5

How to draw a circle on a Flutter Canvas?

+19 면접 질문

다음 면접을 위해 Flutter을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기