setPainter method

OverlappingPainter? setPainter(
  1. Offset offset,
  2. String textValue,
  3. double value,
  4. double scale,
  5. Color painterColor, {
  6. CircleData circleData = CircleData.none,
  7. Color backColor = Colors.grey,
  8. Color? textColor = Colors.black,
})

Calculations for painting TextSpan.

Implementation

OverlappingPainter? setPainter(
  Offset offset,
  String textValue,
  double value,
  double scale,
  Color painterColor, {
  CircleData circleData = CircleData.none,
  Color backColor = Colors.grey,
  Color? textColor = Colors.black,
}) {
  double w = contextSize?.width.roundToDouble() ?? 0.0;

  /// Show graph values
  final textSpan = TextSpan(
    children: <TextSpan>[
      TextSpan(
        text: textValue.substring(0, textValue.length),
        style: TextStyle(
          color: textColor,
        ),
      ),
    ],
  );
  RenderBox box = globalKey?.currentContext?.findRenderObject() as RenderBox;
  if (value >= 0) {
    /// Calling overlapping graphs.
    return OverlappingPainter(
      widgetSize: box.size.width,
      circleData: circleData,
      radData: radData,
      backgroundColor: painterColor,
      offsetValue: offset,
      textSpan: textSpan,
      value: (animationValue ?? 0.0) - (value * 0.1 * scale),
      graphCount: graphCount,
      contextSize:
          Size(w * (value * 0.1 * scale), contextSize?.height ?? 0.0),
      dialogData: dialogData,
      controller: streamController,
    );
  } else {
    return OverlappingPainter(
      widgetSize: box.size.width,
      circleData: circleData,
      radData: radData,
      backgroundColor: backColor,
      offsetValue: offset,
      textSpan: textSpan,
      value: null,
      graphCount: null,
      contextSize: const Size(0, 0),
      dialogData: dialogData,
      controller: streamController,
    );
  }
}