build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Builds the progress bar widget, handling determinate and indeterminate modes with smooth animations via AnimatedValueBuilder and RepeatedAnimationBuilder. For determinate mode, interpolates properties using _LinearProgressIndicatorProperties and paints via _LinearProgressIndicatorPainter. Indeterminate mode cycles two progress segments with predefined curves for fluid motion. Wraps in ClipRRect for border radius and SizedBox for height, ensuring RTL support via Directionality and theme integration with ArcaneTheme.

Implementation

@override
Widget build(BuildContext context) {
  final theme = Theme.of(context);
  final directionality = Directionality.of(context);
  Widget childWidget;
  if (value != null) {
    childWidget = AnimatedValueBuilder(
        value: _LinearProgressIndicatorProperties(
          start: 0,
          end: value!.clamp(0, 1),
          color: color ?? theme.colorScheme.primary,
          backgroundColor:
              backgroundColor ?? theme.colorScheme.primary.scaleAlpha(0.2),
          showSparks: showSparks,
          sparksColor: color ?? theme.colorScheme.primary,
          sparksRadius: theme.scaling * 16,
          textDirection: directionality,
        ),
        duration: disableAnimation ? Duration.zero : kDefaultDurationX,
        lerp: _LinearProgressIndicatorProperties.lerp,
        curve: Curves.easeOutExpo,
        builder: (context, value, child) {
          return CustomPaint(
            painter: _LinearProgressIndicatorPainter(
              start: 0,
              end: value.end,
              start2: value.start2,
              end2: value.end2,
              color: value.color,
              backgroundColor: value.backgroundColor,
              showSparks: value.showSparks,
              sparksColor: value.sparksColor,
              sparksRadius: value.sparksRadius,
              textDirection: value.textDirection,
            ),
          );
        });
  } else {
    // indeterminate
    childWidget = RepeatedAnimationBuilder(
      start: 0.0,
      end: 1.0,
      duration: const Duration(milliseconds: _kIndeterminateLinearDuration),
      builder: (context, value, child) {
        double start = _line1Tail.transform(value);
        double end = _line1Head.transform(value);
        double start2 = _line2Tail.transform(value);
        double end2 = _line2Head.transform(value);
        return AnimatedValueBuilder(
            duration: kDefaultDurationX,
            lerp: _LinearProgressIndicatorProperties.lerp,
            value: _LinearProgressIndicatorProperties(
              start: start,
              end: end,
              start2: start2,
              end2: end2,
              color: color ?? theme.colorScheme.primary,
              backgroundColor: backgroundColor ??
                  theme.colorScheme.primary.scaleAlpha(0.2),
              showSparks: showSparks,
              sparksColor: color ?? theme.colorScheme.primary,
              sparksRadius: theme.scaling * 16,
              textDirection: directionality,
            ),
            builder: (context, prop, child) {
              return CustomPaint(
                painter: _LinearProgressIndicatorPainter(
                  // do not animate start and end value
                  start: start,
                  end: end,
                  start2: start2,
                  end2: end2,
                  color: prop.color,
                  backgroundColor: prop.backgroundColor,
                  showSparks: prop.showSparks,
                  sparksColor: prop.sparksColor,
                  sparksRadius: prop.sparksRadius,
                  textDirection: prop.textDirection,
                ),
              );
            });
      },
    );
  }
  return RepaintBoundary(
    child: SizedBox(
      height: minHeight ?? (theme.scaling * 2),
      child: ClipRRect(
        borderRadius: borderRadius ?? BorderRadius.zero,
        child: childWidget,
      ),
    ),
  );
}