Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
custom_pin_widget.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2
3class CustomPinWidget extends StatelessWidget {
4 final Color color;
5 final double size;
6 final bool hasShadow;
7
9 super.key,
10 required this.color,
11 required this.size,
12 this.hasShadow = false,
13 });
14
15 @override
16 Widget build(BuildContext context) {
17 return SizedBox(
18 width: size,
19 height: size * 1.4,
20 child: Stack(
21 alignment: Alignment.topCenter,
22 children: [
23 if (hasShadow)
24 Positioned(
25 bottom: -10,
26 left: (size - size * 0.6) / 2,
27 child: Container(
28 width: size * 0.6,
29 height: size * 0.15,
30 decoration: BoxDecoration(
31 borderRadius: BorderRadius.circular(size * 0.9),
32 color: Colors.black.withValues(alpha: 0.8),
33 ),
34 ),
35 ),
36 CustomPaint(
37 size: Size(size, size * 1.4),
38 painter: PinPainter(color: color),
39 ),
40 Positioned(
41 top: size * 0.25,
42 child: Container(
43 width: size * 0.3,
44 height: size * 0.3,
45 decoration: const BoxDecoration(
46 color: Colors.white,
47 shape: BoxShape.circle,
48 ),
49 ),
50 ),
51 ],
52 ),
53 );
54 }
55}
56
57class PinPainter extends CustomPainter {
58 final Color color;
59
60 PinPainter({required this.color});
61
62 @override
63 void paint(Canvas canvas, Size size) {
64 final paint = Paint()
65 ..color = color
66 ..style = PaintingStyle.fill;
67
68 final circleRadius = size.width * 0.4;
69 final circleCenter = Offset(size.width / 2, circleRadius);
70
71 canvas.drawCircle(circleCenter, circleRadius, paint);
72
73 final lineWidth = size.width * 0.1;
74 final lineBottom = Offset(size.width / 2, size.height);
75
76 final rect = Rect.fromLTRB(
77 size.width / 2 - lineWidth / 2,
78 circleRadius * 1.6,
79 size.width / 2 + lineWidth / 2,
80 size.height,
81 );
82
83 canvas.drawRect(rect, paint);
84 canvas.drawCircle(lineBottom, lineWidth / 2, paint);
85 }
86
87 @override
88 bool shouldRepaint(CustomPainter oldDelegate) => false;
89}
override bool shouldRepaint(SplashScreenCirclesPainter oldDelegate)
override void paint(Canvas canvas, Size size)
final Widget child
override Widget build(BuildContext context)
const CustomPinWidget({ super.key, required this.color, required this.size, this.hasShadow=false, })
override void paint(Canvas canvas, Size size)
PinPainter({required this.color})
final Color color
Definition failures.dart:1
style SizedBox(height:2.h)