Created
November 7, 2023 14:58
-
-
Save felipecastrosales/19e1afc0611b8daeaa53804c63933bb4 to your computer and use it in GitHub Desktop.
painterrrr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:ui'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp( | |
MaterialApp( | |
home: Scaffold( | |
appBar: AppBar( | |
title: const Text('Custom Painter Example'), | |
), | |
body: const CustomPaint( | |
painter: RetroLineCurvedPainter( | |
color: Colors.red, | |
)), | |
), | |
), | |
); | |
} | |
class RetroLineCurvedPainter extends CustomPainter { | |
const RetroLineCurvedPainter({ | |
required this.color, | |
}); | |
final Color color; | |
@override | |
void paint(Canvas canvas, Size size) { | |
final path1 = Path() | |
..moveTo(146, 614) | |
..lineTo(216, 614) | |
..lineTo(216, 808) | |
..lineTo(146, 808) | |
..close(); | |
final paint1Fill = Paint() | |
..style = PaintingStyle.fill | |
..color = color; | |
canvas.drawPath(path1, paint1Fill); | |
final path2 = Path() | |
..moveTo(58, 374) | |
..lineTo(128, 374) | |
..lineTo(128, 568) | |
..lineTo(58, 568) | |
..close(); | |
final paint2Fill = Paint() | |
..style = PaintingStyle.fill | |
..color = color; | |
canvas.drawPath(path2, paint2Fill); | |
final path3 = Path() | |
..moveTo(118, 0) | |
..lineTo(242, 0) | |
..lineTo(242, 309) | |
..lineTo(118, 309) | |
..close(); | |
final paint3Fill = Paint() | |
..style = PaintingStyle.fill | |
..color = color; | |
canvas.drawPath(path3, paint3Fill); | |
final path4 = Path() | |
..moveTo(58, 568) | |
..lineTo(128, 568) | |
..lineTo(216, 614) | |
..lineTo(146, 614) | |
..lineTo(58, 568) | |
..close(); | |
final paint4Fill = Paint() | |
..style = PaintingStyle.fill | |
..color = color; | |
canvas.drawPath(path4, paint4Fill); | |
final path5 = Path() | |
..moveTo(58, 568) | |
..lineTo(128, 568) | |
..lineTo(216, 614) | |
..lineTo(146, 614) | |
..lineTo(58, 568) | |
..close(); | |
final paint5Fill = Paint()..style = PaintingStyle.fill; | |
paint5Fill.color = Colors.black.withOpacity(0.2); | |
canvas.drawPath(path5, paint5Fill); | |
final path6 = Path() | |
..moveTo(58, 375) | |
..lineTo(128, 375) | |
..lineTo(241.5, 309) | |
..lineTo(118, 309) | |
..lineTo(58, 375) | |
..close(); | |
final paint6Fill = Paint() | |
..style = PaintingStyle.fill | |
..color = color; | |
canvas.drawPath(path6, paint6Fill); | |
final path7 = Path() | |
..moveTo(58, 375) | |
..lineTo(128, 375) | |
..lineTo(241.5, 309) | |
..lineTo(118, 309) | |
..lineTo(58, 375) | |
..close(); | |
final paint7Fill = Paint()..style = PaintingStyle.fill; | |
paint7Fill.color = Colors.black.withOpacity(0.2); | |
canvas.drawPath(path7, paint7Fill); | |
} | |
@override | |
bool shouldRepaint(covariant CustomPainter oldDelegate) => false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment