반응형
해결 방법
플러터에서는 upright 방향으로밖에 그림을 그릴 수 있다. 따라서 회전한 Object 를 그리는 것이 아니다. canvas를 회전시킨 뒤에 Object 를 그리고, 다시 회전시킴으로서 Object 가 회전된 것처럼 보이게 하는 것이ㅏㄷ.
void drawRotated(
Canvas canvas,
Offset center,
double angle,
VoidCallback drawFunction,
) {
canvas.save();
canvas.translate(center.dx, center.dy);
canvas.rotate(angle);
canvas.translate(-center.dx, -center.dy);
drawFunction();
canvas.restore();
}
실행 결과
Reference
https://www.flutterclutter.dev/flutter/tutorials/2022-04-17-rotate-custom-paint-canvas-flutter/
반응형
'Mobile APP > Flutter' 카테고리의 다른 글
[Flutter] Abstract class 를 get_it 에 넣어 사용하기 (0) | 2023.02.17 |
---|---|
[Flutter] dashed line 그리기 (0) | 2023.02.15 |
[Flutter] Custom Paint Border Radius 있는 rect 그리기 (0) | 2023.02.15 |
[Flutter] M1 pod install 'CocoaPods could not find compatible versions for pod "FBAudienceNetwork"' 해결 (0) | 2023.01.28 |
[Flutter] 중복 클릭 방지 버튼, StreamController, Throttle 버튼 구현 (0) | 2022.12.07 |
댓글