paint method

  1. @override
void paint(
  1. Canvas canvas,
  2. Size size
)
override

Called whenever the object needs to paint. The given Canvas has its coordinate space configured such that the origin is at the top left of the box. The area of the box is the size of the size argument.

Paint operations should remain inside the given area. Graphical operations outside the bounds may be silently ignored, clipped, or not clipped. It may sometimes be difficult to guarantee that a certain operation is inside the bounds (e.g., drawing a rectangle whose size is determined by user inputs). In that case, consider calling Canvas.clipRect at the beginning of paint so everything that follows will be guaranteed to only draw within the clipped area.

Implementations should be wary of correctly pairing any calls to Canvas.save/Canvas.saveLayer and Canvas.restore, otherwise all subsequent painting on this canvas may be affected, with potentially hilarious but confusing results.

To paint text on a Canvas, use a TextPainter.

To paint an image on a Canvas:

  1. Obtain an ImageStream, for example by calling ImageProvider.resolve on an AssetImage or NetworkImage object.

  2. Whenever the ImageStream's underlying ImageInfo object changes (see ImageStream.addListener), create a new instance of your custom paint delegate, giving it the new ImageInfo object.

  3. In your delegate's paint method, call the Canvas.drawImage, Canvas.drawImageRect, or Canvas.drawImageNine methods to paint the ImageInfo.image object, applying the ImageInfo.scale value to obtain the correct rendering size.

Implementation

@override
void paint(Canvas canvas, Size size) {
  final scaleX = size.width / 18.005798324341672;
  final scaleY = size.height / 20.000000734939896;
  final scale = math.min(scaleX, scaleY);

  final translationX = (size.width - 18.005798324341672 * scale) / 2 - 3.0 * scale;
  final translationY = (size.height - 20.000000734939896 * scale) / 2 - 1.999999970089306 * scale;

  final path = Path();
  final paint = Paint()..color = color;

  path.moveTo(
    13.0 * scale + translationX,
    20.0 * scale + translationY,
  );

  path.lineTo(
    6.0 * scale + translationX,
    20.0 * scale + translationY,
  );

  path.cubicTo(
    5.447715250169207 * scale + translationX,
    20.0 * scale + translationY,
    5.0 * scale + translationX,
    19.552284749830793 * scale + translationY,
    5.0 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.lineTo(
    5.0 * scale + translationX,
    5.0 * scale + translationY,
  );

  path.cubicTo(
    5.0 * scale + translationX,
    4.447715250169207 * scale + translationY,
    5.447715250169207 * scale + translationX,
    4.0 * scale + translationY,
    6.0 * scale + translationX,
    4.0 * scale + translationY,
  );

  path.lineTo(
    11.0 * scale + translationX,
    4.0 * scale + translationY,
  );

  path.lineTo(
    11.0 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.cubicTo(
    11.00000027844744 * scale + translationX,
    8.65685452793982 * scale + translationY,
    12.343146097908948 * scale + translationX,
    10.000000347401329 * scale + translationY,
    14.000000417232513 * scale + translationX,
    10.000000298023224 * scale + translationY,
  );

  path.lineTo(
    17.0 * scale + translationX,
    10.0 * scale + translationY,
  );

  path.lineTo(
    17.0 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.cubicTo(
    17.0 * scale + translationX,
    12.552284749830793 * scale + translationY,
    17.447715250169207 * scale + translationX,
    13.0 * scale + translationY,
    18.0 * scale + translationX,
    13.0 * scale + translationY,
  );

  path.cubicTo(
    18.552284749830793 * scale + translationX,
    13.0 * scale + translationY,
    19.0 * scale + translationX,
    12.552284749830793 * scale + translationY,
    19.0 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.lineTo(
    19.0 * scale + translationX,
    9.0 * scale + translationY,
  );

  path.cubicTo(
    19.0 * scale + translationX,
    9.0 * scale + translationY,
    19.0 * scale + translationX,
    9.0 * scale + translationY,
    19.0 * scale + translationX,
    8.94 * scale + translationY,
  );

  path.cubicTo(
    18.989582712457924 * scale + translationX,
    8.848134430197735 * scale + translationY,
    18.969470643609867 * scale + translationX,
    8.757630120381467 * scale + translationY,
    18.939999003368943 * scale + translationX,
    8.66999954378082 * scale + translationY,
  );

  path.lineTo(
    18.94 * scale + translationX,
    8.58 * scale + translationY,
  );

  path.cubicTo(
    18.891919698553018 * scale + translationX,
    8.477180103356682 * scale + translationY,
    18.827784571787767 * scale + translationX,
    8.382665179702625 * scale + translationY,
    18.750000773850715 * scale + translationX,
    8.300000342557919 * scale + translationY,
  );

  path.lineTo(
    18.75 * scale + translationX,
    8.3 * scale + translationY,
  );

  path.lineTo(
    12.75 * scale + translationX,
    2.3000000000000007 * scale + translationY,
  );

  path.lineTo(
    12.75 * scale + translationX,
    2.3000000000000007 * scale + translationY,
  );

  path.cubicTo(
    12.66733568907378 * scale + translationX,
    2.2222162969886416 * scale + translationY,
    12.572820765419722 * scale + translationX,
    2.1580811702233884 * scale + translationY,
    12.470000514662317 * scale + translationX,
    2.1100000870840026 * scale + translationY,
  );

  path.cubicTo(
    12.44014952224849 * scale + translationX,
    2.10576013726435 * scale + translationY,
    12.409849922310727 * scale + translationX,
    2.10576013726435 * scale + translationY,
    12.379999723285437 * scale + translationX,
    2.1099999528378257 * scale + translationY,
  );

  path.cubicTo(
    12.278414616130524 * scale + translationX,
    2.0517413241087925 * scale + translationY,
    12.166223165367144 * scale + translationX,
    2.014344173854332 * scale + translationY,
    12.049999819788066 * scale + translationX,
    1.999999970089306 * scale + translationY,
  );

  path.lineTo(
    6.0 * scale + translationX,
    2.0 * scale + translationY,
  );

  path.cubicTo(
    4.3431458594903685 * scale + translationX,
    2.000000010226537 * scale + translationY,
    3.0000000400288602 * scale + translationX,
    3.343145829688045 * scale + translationY,
    3.000000089406967 * scale + translationX,
    5.000000149011611 * scale + translationY,
  );

  path.lineTo(
    3.0 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.cubicTo(
    3.0000000400288602 * scale + translationX,
    20.65685488556769 * scale + translationY,
    4.3431458594903685 * scale + translationX,
    22.0000007050292 * scale + translationY,
    6.0000001788139325 * scale + translationX,
    22.000000655651093 * scale + translationY,
  );

  path.lineTo(
    13.0 * scale + translationX,
    22.0 * scale + translationY,
  );

  path.cubicTo(
    13.552284749830793 * scale + translationX,
    22.0 * scale + translationY,
    14.0 * scale + translationX,
    21.552284749830793 * scale + translationY,
    14.0 * scale + translationX,
    21.0 * scale + translationY,
  );

  path.cubicTo(
    14.0 * scale + translationX,
    20.447715250169207 * scale + translationY,
    13.552284749830793 * scale + translationX,
    20.0 * scale + translationY,
    13.0 * scale + translationX,
    20.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    13.0 * scale + translationX,
    5.41 * scale + translationY,
  );

  path.lineTo(
    15.59 * scale + translationX,
    8.0 * scale + translationY,
  );

  path.lineTo(
    14.0 * scale + translationX,
    8.0 * scale + translationY,
  );

  path.cubicTo(
    13.447715250169207 * scale + translationX,
    8.0 * scale + translationY,
    13.0 * scale + translationX,
    7.552284749830793 * scale + translationY,
    13.0 * scale + translationX,
    7.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    8.0 * scale + translationX,
    8.0 * scale + translationY,
  );

  path.cubicTo(
    7.447715250169207 * scale + translationX,
    8.0 * scale + translationY,
    7.0 * scale + translationX,
    8.447715250169207 * scale + translationY,
    7.0 * scale + translationX,
    9.0 * scale + translationY,
  );

  path.cubicTo(
    7.0 * scale + translationX,
    9.552284749830793 * scale + translationY,
    7.447715250169207 * scale + translationX,
    10.0 * scale + translationY,
    8.0 * scale + translationX,
    10.0 * scale + translationY,
  );

  path.lineTo(
    9.0 * scale + translationX,
    10.0 * scale + translationY,
  );

  path.cubicTo(
    9.552284749830793 * scale + translationX,
    10.0 * scale + translationY,
    10.0 * scale + translationX,
    9.552284749830793 * scale + translationY,
    10.0 * scale + translationX,
    9.0 * scale + translationY,
  );

  path.cubicTo(
    10.0 * scale + translationX,
    8.447715250169207 * scale + translationY,
    9.552284749830793 * scale + translationX,
    8.0 * scale + translationY,
    9.0 * scale + translationX,
    8.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    14.0 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.lineTo(
    8.0 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.cubicTo(
    7.447715250169207 * scale + translationX,
    12.0 * scale + translationY,
    7.0 * scale + translationX,
    12.447715250169207 * scale + translationY,
    7.0 * scale + translationX,
    13.0 * scale + translationY,
  );

  path.cubicTo(
    7.0 * scale + translationX,
    13.552284749830793 * scale + translationY,
    7.447715250169207 * scale + translationX,
    14.0 * scale + translationY,
    8.0 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.lineTo(
    14.0 * scale + translationX,
    14.0 * scale + translationY,
  );

  path.cubicTo(
    14.552284749830793 * scale + translationX,
    14.0 * scale + translationY,
    15.0 * scale + translationX,
    13.552284749830793 * scale + translationY,
    15.0 * scale + translationX,
    13.0 * scale + translationY,
  );

  path.cubicTo(
    15.0 * scale + translationX,
    12.447715250169207 * scale + translationY,
    14.552284749830793 * scale + translationX,
    12.0 * scale + translationY,
    14.0 * scale + translationX,
    12.0 * scale + translationY,
  );

  path.close();

  path.moveTo(
    20.71 * scale + translationX,
    17.29 * scale + translationY,
  );

  path.lineTo(
    18.71 * scale + translationX,
    15.29 * scale + translationY,
  );

  path.cubicTo(
    18.614896290305705 * scale + translationX,
    15.198959370682967 * scale + translationY,
    18.502751317722428 * scale + translationX,
    15.127594388129973 * scale + translationY,
    18.380000000000003 * scale + translationX,
    15.079999999999998 * scale + translationY,
  );

  path.cubicTo(
    18.136538644253427 * scale + translationX,
    14.979981981850363 * scale + translationY,
    17.863461355746576 * scale + translationX,
    14.979981981850361 * scale + translationY,
    17.62 * scale + translationX,
    15.079999999999997 * scale + translationY,
  );

  path.cubicTo(
    17.497248682277576 * scale + translationX,
    15.127594388129973 * scale + translationY,
    17.3851037096943 * scale + translationX,
    15.198959370682967 * scale + translationY,
    17.29 * scale + translationX,
    15.29 * scale + translationY,
  );

  path.lineTo(
    15.29 * scale + translationX,
    17.29 * scale + translationY,
  );

  path.cubicTo(
    14.897878096986046 * scale + translationX,
    17.682122467299486 * scale + translationY,
    14.897878096986046 * scale + translationX,
    18.3178781169428 * scale + translationY,
    15.290000265913811 * scale + translationX,
    18.710000285870567 * scale + translationY,
  );

  path.cubicTo(
    15.682122434841578 * scale + translationX,
    19.102122454798334 * scale + translationY,
    16.317878084484896 * scale + translationX,
    19.102122454798334 * scale + translationY,
    16.710000253412662 * scale + translationX,
    18.710000285870567 * scale + translationY,
  );

  path.lineTo(
    17.0 * scale + translationX,
    18.41 * scale + translationY,
  );

  path.lineTo(
    17.0 * scale + translationX,
    21.0 * scale + translationY,
  );

  path.cubicTo(
    17.0 * scale + translationX,
    21.552284749830793 * scale + translationY,
    17.447715250169207 * scale + translationX,
    22.0 * scale + translationY,
    18.0 * scale + translationX,
    22.0 * scale + translationY,
  );

  path.cubicTo(
    18.552284749830793 * scale + translationX,
    22.0 * scale + translationY,
    19.0 * scale + translationX,
    21.552284749830793 * scale + translationY,
    19.0 * scale + translationX,
    21.0 * scale + translationY,
  );

  path.lineTo(
    19.0 * scale + translationX,
    18.41 * scale + translationY,
  );

  path.lineTo(
    19.29 * scale + translationX,
    18.71 * scale + translationY,
  );

  path.cubicTo(
    19.477766599905554 * scale + translationX,
    18.8993126508231 * scale + translationY,
    19.73336246362944 * scale + translationX,
    19.005798324341672 * scale + translationY,
    20.0 * scale + translationX,
    19.005798324341672 * scale + translationY,
  );

  path.cubicTo(
    20.26663753637056 * scale + translationX,
    19.005798324341672 * scale + translationY,
    20.522233400094446 * scale + translationX,
    18.8993126508231 * scale + translationY,
    20.71 * scale + translationX,
    18.71 * scale + translationY,
  );

  path.cubicTo(
    20.8993126508231 * scale + translationX,
    18.522233400094446 * scale + translationY,
    21.005798324341672 * scale + translationX,
    18.26663753637056 * scale + translationY,
    21.005798324341672 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    21.005798324341672 * scale + translationX,
    17.73336246362944 * scale + translationY,
    20.8993126508231 * scale + translationX,
    17.477766599905557 * scale + translationY,
    20.71 * scale + translationX,
    17.29 * scale + translationY,
  );

  path.close();

  path.moveTo(
    12.0 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.cubicTo(
    12.552284749830793 * scale + translationX,
    18.0 * scale + translationY,
    13.0 * scale + translationX,
    17.552284749830793 * scale + translationY,
    13.0 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    13.0 * scale + translationX,
    16.447715250169207 * scale + translationY,
    12.552284749830793 * scale + translationX,
    16.0 * scale + translationY,
    12.0 * scale + translationX,
    16.0 * scale + translationY,
  );

  path.lineTo(
    8.0 * scale + translationX,
    16.0 * scale + translationY,
  );

  path.cubicTo(
    7.447715250169207 * scale + translationX,
    16.0 * scale + translationY,
    7.0 * scale + translationX,
    16.447715250169207 * scale + translationY,
    7.0 * scale + translationX,
    17.0 * scale + translationY,
  );

  path.cubicTo(
    7.0 * scale + translationX,
    17.552284749830793 * scale + translationY,
    7.447715250169207 * scale + translationX,
    18.0 * scale + translationY,
    8.0 * scale + translationX,
    18.0 * scale + translationY,
  );

  path.close();

  canvas.drawPath(path, paint);
}