content: import 'package:flutter/material.dart';
  
  import '../../menstrual_cycle_widget.dart';
  import '../custom_painter/dash_painter.dart';
  
  class DottedBorder extends StatelessWidget {
    final Widget child;
    final EdgeInsets padding;
    final EdgeInsets borderPadding;
    final double strokeWidth;
    final Color color;
    final List<double> dashPattern;
    final BorderType borderType;
    final Radius radius;
    final StrokeCap strokeCap;
    final PathBuilder? customPath;
    final StackFit stackFit;
  
    DottedBorder({
      super.key,
      required this.child,
      this.color = Colors.black,
      this.strokeWidth = 1,
      this.borderType = BorderType.rect,
      this.dashPattern = const <double>[3, 1],
      this.padding = const EdgeInsets.all(2),
      this.borderPadding = EdgeInsets.zero,
      this.radius = const Radius.circular(0),
      this.strokeCap = StrokeCap.butt,
      this.customPath,
      this.stackFit = StackFit.loose,
    }) {
      assert(_isValidDashPattern(dashPattern), 'Invalid dash pattern');
    }
  
    @override
    Widget build(BuildContext context) {
      return Stack(
        fit: stackFit,
        children: <Widget>[
          Positioned.fill(
            child: CustomPaint(
              painter: DashedPainter(
                padding: borderPadding,
                strokeWidth: strokeWidth,
                radius: radius,
                color: color,
                borderType: borderType,
                dashPattern: dashPattern,
                customPath: customPath,
                strokeCap: strokeCap,
              ),
            ),
          ),
          Padding(
            padding: padding,
            child: child,
          ),
        ],
      );
    }
  
    /// Compute if [dashPattern] is valid. The following conditions need to be met
    /// * Cannot be null or empty
    /// * If [dashPattern] has only 1 element, it cannot be 0
    bool _isValidDashPattern(List<double>? dashPattern) {
      Set<double>? dashSet = dashPattern?.toSet();
      if (dashSet == null) return false;
      if (dashSet.length == 1 && dashSet.elementAt(0) == 0.0) return false;
      if (dashSet.isEmpty) return false;
      return true;
    }
  }
  