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.04204463399775;
  final scaleY = size.height / 20.054398036529673;
  final scale = math.min(scaleX, scaleY);

  final translationX = (size.width - 18.04204463399775 * scale) / 2 - 2.5 * scale;
  final translationY = (size.height - 20.054398036529673 * scale) / 2 - 1.5499999968154918 * scale;

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

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

  path.cubicTo(
    13.5 * scale + translationX,
    11.947715250169207 * scale + translationY,
    13.052284749830793 * scale + translationX,
    11.5 * scale + translationY,
    12.5 * scale + translationX,
    11.5 * scale + translationY,
  );

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

  path.cubicTo(
    6.947715250169207 * scale + translationX,
    11.5 * scale + translationY,
    6.5 * scale + translationX,
    11.947715250169207 * scale + translationY,
    6.5 * scale + translationX,
    12.5 * scale + translationY,
  );

  path.cubicTo(
    6.5 * scale + translationX,
    13.052284749830793 * scale + translationY,
    6.947715250169207 * scale + translationX,
    13.5 * scale + translationY,
    7.5 * scale + translationX,
    13.5 * scale + translationY,
  );

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

  path.cubicTo(
    13.052284749830793 * scale + translationX,
    13.5 * scale + translationY,
    13.5 * scale + translationX,
    13.052284749830793 * scale + translationY,
    13.5 * scale + translationX,
    12.5 * scale + translationY,
  );

  path.close();

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

  path.cubicTo(
    18.075231564787984 * scale + translationX,
    17.501394147692288 * scale + translationY,
    17.661938144208122 * scale + translationX,
    17.63799112568055 * scale + translationY,
    17.32 * scale + translationX,
    17.89 * scale + translationY,
  );

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

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

  path.cubicTo(
    17.781883514151314 * scale + translationX,
    16.39325980699566 * scale + translationY,
    18.126909142451186 * scale + translationX,
    16.493317239202618 * scale + translationY,
    18.48 * scale + translationX,
    16.5 * scale + translationY,
  );

  path.cubicTo(
    19.584569499661587 * scale + translationX,
    16.5 * scale + translationY,
    20.48 * scale + translationX,
    15.604569499661586 * scale + translationY,
    20.48 * scale + translationX,
    14.5 * scale + translationY,
  );

  path.cubicTo(
    20.48 * scale + translationX,
    13.395430500338414 * scale + translationY,
    19.584569499661587 * scale + translationX,
    12.5 * scale + translationY,
    18.48 * scale + translationX,
    12.5 * scale + translationY,
  );

  path.cubicTo(
    17.375430500338414 * scale + translationX,
    12.5 * scale + translationY,
    16.48 * scale + translationX,
    13.395430500338414 * scale + translationY,
    16.48 * scale + translationX,
    14.5 * scale + translationY,
  );

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

  path.cubicTo(
    13.878851224703888 * scale + translationX,
    14.86542391809935 * scale + translationY,
    12.92276308240381 * scale + translationX,
    14.879737645873668 * scale + translationY,
    12.227037793376658 * scale + translationX,
    15.405376233916305 * scale + translationY,
  );

  path.cubicTo(
    11.531312504349504 * scale + translationX,
    15.931014821958943 * scale + translationY,
    11.256320365070327 * scale + translationX,
    16.846814331668504 * scale + translationY,
    11.547397492983457 * scale + translationX,
    17.668765491189077 * scale + translationY,
  );

  path.cubicTo(
    11.838474620896587 * scale + translationX,
    18.49071665070965 * scale + translationY,
    12.628525387832743 * scale + translationX,
    19.029353081257383 * scale + translationY,
    13.5 * scale + translationX,
    19.0 * scale + translationY,
  );

  path.cubicTo(
    13.822164659584027 * scale + translationX,
    19.00014883670668 * scale + translationY,
    14.138962494055962 * scale + translationX,
    18.91750592336618 * scale + translationY,
    14.419999860285698 * scale + translationX,
    18.759999818235766 * scale + translationY,
  );

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

  path.cubicTo(
    16.643414159239857 * scale + translationX,
    20.825839796357467 * scale + translationY,
    17.58589171520079 * scale + translationX,
    21.604398033345163 * scale + translationY,
    18.655865475432396 * scale + translationX,
    21.524387542682724 * scale + translationY,
  );

  path.cubicTo(
    19.725839235664 * scale + translationX,
    21.444377052020286 * scale + translationY,
    20.54204463399775 * scale + translationX,
    20.53430803287815 * scale + translationY,
    20.50556992742347 * scale + translationX,
    19.461967078712675 * scale + translationY,
  );

  path.cubicTo(
    20.469095220849187 * scale + translationX,
    18.389626124547203 * scale + translationY,
    19.592937469383703 * scale + translationX,
    17.537121305547075 * scale + translationY,
    18.52 * scale + translationX,
    17.53 * scale + translationY,
  );

  path.close();

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

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

  path.cubicTo(
    4.947715250169207 * scale + translationX,
    19.5 * scale + translationY,
    4.5 * scale + translationX,
    19.052284749830793 * scale + translationY,
    4.5 * scale + translationX,
    18.5 * scale + translationY,
  );

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

  path.cubicTo(
    4.5 * scale + translationX,
    3.9477152501692068 * scale + translationY,
    4.947715250169207 * scale + translationX,
    3.5 * scale + translationY,
    5.5 * scale + translationX,
    3.5 * scale + translationY,
  );

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

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

  path.cubicTo(
    10.500000263546278 * scale + translationX,
    8.15685451303866 * scale + translationY,
    11.843146083007786 * scale + translationX,
    9.500000332500168 * scale + translationY,
    13.500000402331352 * scale + translationX,
    9.500000283122063 * scale + translationY,
  );

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

  path.cubicTo(
    16.5 * scale + translationX,
    10.052284749830793 * scale + translationY,
    16.947715250169207 * scale + translationX,
    10.5 * scale + translationY,
    17.5 * scale + translationX,
    10.5 * scale + translationY,
  );

  path.cubicTo(
    18.052284749830793 * scale + translationX,
    10.5 * scale + translationY,
    18.5 * scale + translationX,
    10.052284749830793 * scale + translationY,
    18.5 * scale + translationX,
    9.5 * scale + translationY,
  );

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

  path.cubicTo(
    18.5 * scale + translationX,
    8.5 * scale + translationY,
    18.5 * scale + translationX,
    8.5 * scale + translationY,
    18.5 * scale + translationX,
    8.44 * scale + translationY,
  );

  path.cubicTo(
    18.489582738768142 * scale + translationX,
    8.348134456507953 * scale + translationY,
    18.469470669920085 * scale + translationX,
    8.257630146691685 * scale + translationY,
    18.43999902967916 * scale + translationX,
    8.169999570091038 * scale + translationY,
  );

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

  path.cubicTo(
    18.391919677917 * scale + translationX,
    7.977180082720664 * scale + translationY,
    18.327784551151748 * scale + translationX,
    7.882665159066605 * scale + translationY,
    18.2500007532147 * scale + translationX,
    7.800000321921899 * scale + translationY,
  );

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

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

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

  path.cubicTo(
    12.167335668437762 * scale + translationX,
    1.7222162763526216 * scale + translationY,
    12.072820744783703 * scale + translationX,
    1.6580811495873677 * scale + translationY,
    11.970000494026298 * scale + translationX,
    1.6100000664479819 * scale + translationY,
  );

  path.cubicTo(
    11.93691759672937 * scale + translationX,
    1.6042094433533491 * scale + translationY,
    11.90308131940992 * scale + translationX,
    1.6042094433533491 * scale + translationY,
    11.869999460342841 * scale + translationX,
    1.6099999268030305 * scale + translationY,
  );

  path.cubicTo(
    11.786089783598538 * scale + translationX,
    1.579523621241113 * scale + translationY,
    11.69878091447921 * scale + translationX,
    1.5593754206751151 * scale + translationY,
    11.610000597644945 * scale + translationX,
    1.5500000797889455 * scale + translationY,
  );

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

  path.cubicTo(
    3.8431458445892073 * scale + translationX,
    1.5499999968154918 * scale + translationY,
    2.5000000251276986 * scale + translationX,
    2.8931458162770003 * scale + translationY,
    2.500000074505806 * scale + translationX,
    4.550000135600566 * scale + translationY,
  );

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

  path.cubicTo(
    2.500000025127699 * scale + translationX,
    20.206854872156647 * scale + translationY,
    3.843145844589206 * scale + translationX,
    21.550000691618155 * scale + translationY,
    5.500000163912771 * scale + translationX,
    21.55000064224005 * scale + translationY,
  );

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

  path.cubicTo(
    11.052284749830793 * scale + translationX,
    21.55 * scale + translationY,
    11.5 * scale + translationX,
    21.102284749830794 * scale + translationY,
    11.5 * scale + translationX,
    20.55 * scale + translationY,
  );

  path.cubicTo(
    11.5 * scale + translationX,
    19.997715250169207 * scale + translationY,
    11.052284749830793 * scale + translationX,
    19.55 * scale + translationY,
    10.5 * scale + translationX,
    19.55 * scale + translationY,
  );

  path.close();

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

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

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

  path.cubicTo(
    12.947715250169207 * scale + translationX,
    7.5 * scale + translationY,
    12.5 * scale + translationX,
    7.052284749830793 * scale + translationY,
    12.5 * scale + translationX,
    6.5 * scale + translationY,
  );

  path.close();

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

  path.cubicTo(
    6.947715250169207 * scale + translationX,
    15.5 * scale + translationY,
    6.5 * scale + translationX,
    15.947715250169207 * scale + translationY,
    6.5 * scale + translationX,
    16.5 * scale + translationY,
  );

  path.cubicTo(
    6.5 * scale + translationX,
    17.052284749830793 * scale + translationY,
    6.947715250169207 * scale + translationX,
    17.5 * scale + translationY,
    7.5 * scale + translationX,
    17.5 * scale + translationY,
  );

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

  path.cubicTo(
    9.052284749830793 * scale + translationX,
    17.5 * scale + translationY,
    9.5 * scale + translationX,
    17.052284749830793 * scale + translationY,
    9.5 * scale + translationX,
    16.5 * scale + translationY,
  );

  path.cubicTo(
    9.5 * scale + translationX,
    15.947715250169207 * scale + translationY,
    9.052284749830793 * scale + translationX,
    15.5 * scale + translationY,
    8.5 * scale + translationX,
    15.5 * scale + translationY,
  );

  path.close();

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

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

  path.cubicTo(
    9.052284749830793 * scale + translationX,
    9.5 * scale + translationY,
    9.5 * scale + translationX,
    9.052284749830793 * scale + translationY,
    9.5 * scale + translationX,
    8.5 * scale + translationY,
  );

  path.cubicTo(
    9.5 * scale + translationX,
    7.947715250169207 * scale + translationY,
    9.052284749830793 * scale + translationX,
    7.5 * scale + translationY,
    8.5 * scale + translationX,
    7.5 * scale + translationY,
  );

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

  path.cubicTo(
    6.947715250169207 * scale + translationX,
    7.5 * scale + translationY,
    6.5 * scale + translationX,
    7.947715250169207 * scale + translationY,
    6.5 * scale + translationX,
    8.5 * scale + translationY,
  );

  path.cubicTo(
    6.5 * scale + translationX,
    9.052284749830793 * scale + translationY,
    6.947715250169207 * scale + translationX,
    9.5 * scale + translationY,
    7.5 * scale + translationX,
    9.5 * scale + translationY,
  );

  path.close();

  canvas.drawPath(path, paint);
}