ArcTextPainter constructor
ArcTextPainter({})
Implementation
ArcTextPainter({
required num radius,
required String text,
TextStyle? textStyle,
StartAngleAlignment alignment = StartAngleAlignment.start,
double initialAngle = 0,
this.direction = Direction.clockwise,
Placement placement = Placement.outside,
double? stretchAngle,
double? interLetterAngle,
}) : assert(
stretchAngle == null || interLetterAngle == null,
'stretchAngle and interLetterAngle should not be both not null',
),
radius = radius.toDouble(),
_text = text,
_textStyle = textStyle {
_textPainter
..text = TextSpan(text: _text, style: textStyle)
..layout(minWidth: 0, maxWidth: double.maxFinite);
switch (placement) {
case Placement.inside:
_effectiveRadius = this.radius - _textPainter.height;
case Placement.outside:
_effectiveRadius = this.radius;
case Placement.middle:
_effectiveRadius = this.radius - _textPainter.height / 2;
}
_interLetterAngle = (stretchAngle != null && _text.characters.length > 1)
? (stretchAngle -
_calculateSweepAngle(
_textPainter,
_textStyle,
_effectiveRadius,
_text,
0,
)) /
_text.characters.length
: interLetterAngle ?? 0;
final double alignmentOffset =
_getAlignmentOffset(alignment, stretchAngle ?? sweepAngle);
switch (direction) {
case Direction.clockwise:
_angleWithAlignment = initialAngle + alignmentOffset;
_angleMultiplier = 1;
_heightOffset = -_effectiveRadius - _textPainter.height;
case Direction.counterClockwise:
_angleWithAlignment = initialAngle - alignmentOffset + math.pi;
_angleMultiplier = -1;
_heightOffset = _effectiveRadius;
}
}