getOneLoadingCircleWidget static method
Implementation
static Widget getOneLoadingCircleWidget({
bool? isPaintAnimation,
bool? isPaintStartStiff,
double? side,
double? stroke,
Duration? duration,
Color? colorBig,
Color? colorSmall,
}) {
isPaintAnimation ??= false;
isPaintStartStiff ??= false;
side ??= 64.0;
stroke ??= 4.0;
double radius = side / 2;
double strokeWidth = stroke;
Size size = Size(side, side);
Duration time = duration ?? const Duration(milliseconds: 1000);
if (!isPaintAnimation) {
return RotateWidget(
child: CustomPaint(
size: size,
painter: LoadingIconPainter(
radius: radius,
strokeWidth: strokeWidth,
color1st: colorBig,
color2nd: colorSmall,
),
),
);
}
Widget paintView;
Widget getPainterView(bool isRepeatWithReverse, List<double> Function(double progress) getAngels) {
return getOnePainterWidget(
size: size,
isRepeat: true,
duration: time,
isRepeatWithReverse: isRepeatWithReverse,
painter: (progress) {
List<double> ratios = getAngels(progress);
return LoadingIconPainter(
radius: radius,
strokeWidth: strokeWidth,
ratio1stPoint: ratios.first,
ratio1stSweep: ratios.last,
color1st: colorBig,
color2nd: colorSmall,
);
},
);
}
if (isPaintStartStiff) {
double _previous = 0;
int repeatCount = 0;
paintView = getPainterView(false, (progress) {
if (_previous > progress) {
repeatCount++;
}
_previous = progress;
double start = 0.0;
double length = progress + repeatCount;
return [start, length];
});
} else {
double _previous = 0;
bool isReversing = false;
paintView = getPainterView(true, (progress) {
isReversing = _previous > progress;
_previous = progress;
double start = isReversing ? 1.0 - progress : 0.0;
double length = isReversing ? 1.0 - start : progress;
return [start, length];
});
}
return paintView;
}