get method

Paint get({
  1. required String key,
  2. required Color color,
  3. double strokeWidth = 1.0,
  4. PaintingStyle style = PaintingStyle.stroke,
  5. StrokeCap strokeCap = StrokeCap.round,
  6. StrokeJoin strokeJoin = StrokeJoin.round,
  7. bool isAntiAlias = true,
  8. double? opacity,
})

Implementation

Paint get({
  required String key,
  required Color color,
  double strokeWidth = 1.0,
  PaintingStyle style = PaintingStyle.stroke,
  StrokeCap strokeCap = StrokeCap.round,
  StrokeJoin strokeJoin = StrokeJoin.round,
  bool isAntiAlias = true,
  double? opacity,
}) {
  final cacheKey =
      '$key-${color.toARGB32()}-$strokeWidth-$style-$strokeCap-$opacity';
  return _cache.putIfAbsent(cacheKey, () {
    return Paint()
      ..color = opacity != null ? color.withValues(alpha: opacity) : color
      ..strokeWidth = strokeWidth
      ..style = style
      ..strokeCap = strokeCap
      ..strokeJoin = strokeJoin
      ..isAntiAlias = isAntiAlias;
  });
}