78 lines
2.2 KiB
Dart
78 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
class DottedBorderContainer extends StatelessWidget {
|
|
const DottedBorderContainer({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CustomPaint(
|
|
painter: DottedBorderPainter(),
|
|
child: Container(
|
|
height: 300.h,
|
|
width: double.infinity,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(16)),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Image.asset("assets/icons/select_photo.png", scale: 4),
|
|
SizedBox(height: 20.h),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.add_circle_outline,
|
|
color: Color(0xffF95F62),
|
|
size: 25,
|
|
),
|
|
const Text(
|
|
"Add image",
|
|
style: TextStyle(
|
|
color: Color(0xffF95F62),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class DottedBorderPainter extends CustomPainter {
|
|
@override
|
|
void paint(Canvas canvas, Size size) {
|
|
final paint = Paint()
|
|
..color = const Color(0xffF95F62)
|
|
..strokeWidth = 1.5
|
|
..style = PaintingStyle.stroke;
|
|
|
|
const double dashWidth = 6;
|
|
const double dashSpace = 3;
|
|
final path = Path()
|
|
..addRRect(
|
|
RRect.fromRectAndRadius(
|
|
Rect.fromLTWH(0, 0, size.width, size.height),
|
|
const Radius.circular(16),
|
|
),
|
|
);
|
|
|
|
final pathMetrics = path.computeMetrics();
|
|
for (final metric in pathMetrics) {
|
|
double distance = 0.0;
|
|
while (distance < metric.length) {
|
|
final segment = metric.extractPath(distance, distance + dashWidth);
|
|
canvas.drawPath(segment, paint);
|
|
distance += dashWidth + dashSpace;
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
|
}
|