build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the user interface represented by this widget.

The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change (e.g., an InheritedWidget referenced by this widget changes). This method can potentially be called in every frame and should not have any side effects beyond building a widget.

The framework replaces the subtree below this widget with the widget returned by this method, either by updating the existing subtree or by removing the subtree and inflating a new subtree, depending on whether the widget returned by this method can update the root of the existing subtree, as determined by calling Widget.canUpdate.

Typically implementations return a newly created constellation of widgets that are configured with information from this widget's constructor and from the given BuildContext.

The given BuildContext contains information about the location in the tree at which this widget is being built. For example, the context provides the set of inherited widgets for this location in the tree. A given widget might be built with multiple different BuildContext arguments over time if the widget is moved around the tree or if the widget is inserted into the tree in multiple places at once.

The implementation of this method must only depend on:

If a widget's build method is to depend on anything else, use a StatefulWidget instead.

See also:

  • StatelessWidget, which contains the discussion on performance considerations.

Implementation

@override
widgets.Widget build(widgets.BuildContext context) => SvgPicture.string(
      '''
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M26.5 15C28.9853 15 31 12.9853 31 10.5C31 8.01472 28.9853 6 26.5 6C24.0148 6 22 8.01472 22 10.5C22 12.9853 24.0148 15 26.5 15ZM26.5 13C27.8808 13 29 11.8807 29 10.5C29 9.11929 27.8808 8 26.5 8C25.1193 8 24 9.11929 24 10.5C24 11.8807 25.1193 13 26.5 13Z" fill="black"/>
<path d="M29.0586 19.1068C29.6432 19.1068 30.1172 18.6352 30.1172 18.0534C30.1172 17.4716 29.6432 17 29.0586 17C28.474 17 28 17.4716 28 18.0534C28 18.6352 28.474 19.1068 29.0586 19.1068Z" fill="black"/>
<path d="M34.5 42C38.6422 42 42 40.8807 42 39.5C42 38.5416 40.3821 37.7092 38.0071 37.2896C38.115 37.0762 38.1757 36.8352 38.1757 36.5801C38.1757 35.7074 37.4648 35 36.5879 35C35.7109 35 35 35.7074 35 36.5801C35 36.728 35.0205 36.8711 35.0586 37.0068C34.8742 37.0023 34.6879 37 34.5 37C30.3579 37 27 38.1193 27 39.5C27 40.8807 30.3579 42 34.5 42Z" fill="black"/>
<path d="M33.1757 23.5801C33.1757 24.4528 32.4648 25.1602 31.5879 25.1602C30.7109 25.1602 30 24.4528 30 23.5801C30 22.7074 30.7109 22 31.5879 22C32.4648 22 33.1757 22.7074 33.1757 23.5801Z" fill="black"/>
<path d="M36.0586 30.1068C36.6432 30.1068 37.1172 29.6352 37.1172 29.0534C37.1172 28.4716 36.6432 28 36.0586 28C35.474 28 35 28.4716 35 29.0534C35 29.6352 35.474 30.1068 36.0586 30.1068Z" fill="black"/>
<path d="M32.1172 32.0534C32.1172 32.6352 31.6432 33.1068 31.0586 33.1068C30.474 33.1068 30 32.6352 30 32.0534C30 31.4716 30.474 31 31.0586 31C31.6432 31 32.1172 31.4716 32.1172 32.0534Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.6087 14.4363C21.743 13.1099 20.986 11.8551 19.7525 11.3544C19.6873 11.322 19.6196 11.2973 19.5505 11.28C19.5273 11.2722 19.5029 11.2642 19.4772 11.2561C19.3726 11.2231 19.2474 11.1879 19.1025 11.1545C18.8127 11.0876 18.4441 11.0277 18.0064 11.0074C17.1202 10.9662 15.995 11.0891 14.72 11.5907C12.1631 12.5965 9.3478 14.9781 6.5802 19.7717C5.99947 20.7776 5.9472 21.8197 6.03227 22.5993C6.11734 23.3788 6.35965 24.1053 6.61665 24.7107C7.12981 25.9196 7.91251 27.1287 8.63311 28.1251C9.373 29.1481 10.1447 30.0787 10.7225 30.7453C10.8097 30.8459 10.8929 30.941 10.9715 31.03L11.4208 39.1652C11.5121 40.8195 12.9273 42.0866 14.5816 41.9952C16.236 41.9038 17.503 40.4887 17.4116 38.8343L16.9036 29.6365C16.8643 28.9252 16.5727 28.2506 16.0819 27.7343L16.0759 27.728L16.0734 27.7253L16.0335 27.6828C15.9966 27.6432 15.9401 27.5823 15.8671 27.5024C15.7204 27.3418 15.5084 27.1062 15.2563 26.8154C14.7476 26.2285 14.0971 25.4417 13.4948 24.6088C13.3907 24.4649 13.29 24.3223 13.1934 24.1817C13.6703 23.5818 14.1936 22.9956 14.769 22.4264L14.7183 22.9268C14.6322 23.7769 14.9128 24.6234 15.4895 25.2539L19.8694 30.0418C20.9877 31.2644 22.8853 31.3488 24.1078 30.2305C25.3303 29.1122 25.4148 27.2146 24.2965 25.9921L20.8231 22.1951L21.6087 14.4363ZM15.4521 13.4518C16.4512 13.0588 17.2939 12.9764 17.9135 13.0052C18.2214 13.0196 18.4704 13.0611 18.6527 13.1032C18.7438 13.1242 18.8183 13.1454 18.8751 13.1633C18.8893 13.1678 18.9024 13.1721 18.9144 13.1761C18.9624 13.2 19.012 13.2197 19.0627 13.2354C19.4366 13.4178 19.6613 13.8156 19.6189 14.2348L18.7882 22.439C18.7595 22.7223 18.853 23.0045 19.0452 23.2147L22.8208 27.342C23.1935 27.7495 23.1654 28.382 22.7579 28.7548C22.3504 29.1276 21.7178 29.0994 21.3451 28.6919L16.9652 23.904C16.773 23.6938 16.6795 23.4116 16.7081 23.1283L17.0145 20.1029C17.0548 19.7047 16.8538 19.3208 16.5035 19.1271C16.1533 18.9334 15.7212 18.9672 15.4054 19.213C13.6903 20.5479 12.2992 22.0061 11.1626 23.544C10.9176 23.8755 10.9011 24.3233 11.121 24.6719C11.3498 25.0346 11.604 25.4073 11.8742 25.7809C12.5224 26.6771 13.2133 27.5119 13.7451 28.1254C14.0102 28.4312 14.234 28.68 14.3907 28.8516C14.4691 28.9373 14.5306 29.0037 14.572 29.0481L14.6168 29.0959L14.6194 29.0985L14.6303 29.1101L14.6315 29.1114L14.6329 29.1129C14.7965 29.285 14.8936 29.5097 14.9067 29.7468L15.4147 38.9446C15.4451 39.4961 15.0228 39.9678 14.4714 39.9982C13.9199 40.0287 13.4482 39.6064 13.4177 39.0549L12.9492 30.5711C12.9366 30.3439 12.847 30.1278 12.695 29.9585C12.5616 29.8099 12.4058 29.6339 12.2338 29.4354C11.679 28.7953 10.9477 27.9126 10.2537 26.953C9.56622 26.0025 8.88444 24.9346 8.45764 23.9292C8.24422 23.4265 8.07682 22.8987 8.02047 22.3823C7.96397 21.8646 8.01271 21.2906 8.31225 20.7717C10.9391 16.2219 13.4519 14.2387 15.4521 13.4518Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );