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="M18.5739 31.4528C18.9111 31.3634 19.2705 31.4562 19.5223 31.6977L22.7709 34.8136C23.0409 35.0726 23.1437 35.4607 23.0374 35.8194L22.3281 38.2129C22.1511 38.8104 21.7924 39.3379 21.3018 39.7222L16.6587 43.3594C15.3544 44.3811 13.4688 44.1521 12.4471 42.8478C11.4253 41.5435 11.6544 39.6578 12.9587 38.6361L16.8476 35.5896L17.8713 32.1353C17.9704 31.8008 18.2367 31.5422 18.5739 31.4528ZM19.3225 34.2773L18.6745 36.464C18.6154 36.6632 18.4959 36.839 18.3323 36.9671L14.192 40.2105C13.7573 40.5511 13.6809 41.1796 14.0215 41.6144C14.3621 42.0492 14.9906 42.1255 15.4254 41.785L20.0685 38.1477C20.232 38.0196 20.3516 37.8438 20.4106 37.6446L20.9468 35.8353L19.3225 34.2773Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M28 12C29.6569 12 31 10.6569 31 9C31 7.34315 29.6569 6 28 6C26.3432 6 25 7.34315 25 9C25 10.6569 26.3432 12 28 12ZM28 14C30.7614 14 33 11.7614 33 9C33 6.23858 30.7614 4 28 4C25.2386 4 23 6.23858 23 9C23 11.7614 25.2386 14 28 14Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.7368 14.3643C23.1647 13.8336 24.6987 13.8648 26.0759 14.5769C27.3861 15.2543 28.2734 16.3996 28.8315 17.5982C29.0404 18.0466 29.2334 18.4654 29.4139 18.8569C29.8536 19.8107 30.2147 20.5936 30.5591 21.2779C31.0455 22.2445 31.4012 22.8107 31.7152 23.1766C31.9844 23.4902 32.2164 23.6493 32.5136 23.7654C32.8648 23.9026 33.4375 24.0281 34.4562 24.0586C35.9987 24.1049 37.2116 25.3928 37.1654 26.9353C37.1191 28.4778 35.8312 29.6908 34.2887 29.6445C32.9318 29.6038 31.6546 29.4295 30.4805 28.9709C29.252 28.491 28.283 27.7581 27.4747 26.8164C27.3788 26.7047 27.2856 26.5905 27.1948 26.4741L26.7923 28.5778L31.1594 32.8869C31.4375 33.1614 31.6551 33.4912 31.7978 33.855L34.2821 40.1846C34.8459 41.6211 34.1385 43.2426 32.702 43.8065C31.2654 44.3703 29.6439 43.6628 29.0801 42.2263L26.8123 36.4485L18.9534 28.6939C18.3431 28.0917 18.043 27.2426 18.1394 26.3907L18.4643 23.5202C17.5722 24.6741 16.8217 26.0607 16.2982 27.7011C15.829 29.1713 14.2568 29.9827 12.7867 29.5135C11.3166 29.0443 10.5051 27.4721 10.9743 26.002C12.7419 20.4639 16.7405 16.2932 21.7037 14.3768L21.7096 14.3745L21.7368 14.3643ZM22.4363 16.2379L22.4212 16.2437C18.0385 17.9369 14.4674 21.6354 12.8797 26.6101C12.7463 27.028 12.9769 27.4748 13.3948 27.6082C13.8126 27.7415 14.2595 27.5109 14.3929 27.093C15.3866 23.9795 17.1179 21.6246 19.1531 19.9623C19.4681 19.7051 19.9075 19.6642 20.2645 19.8589C20.6215 20.0536 20.8251 20.4452 20.7793 20.8493L20.1268 26.6156C20.0993 26.8577 20.1846 27.0991 20.3581 27.2702L28.3681 35.1738C28.4676 35.2721 28.5455 35.3901 28.5966 35.5203L30.9418 41.4956C31.102 41.9039 31.563 42.105 31.9712 41.9447C32.3796 41.7845 32.5806 41.3236 32.4204 40.9153L29.9361 34.5857C29.8955 34.4823 29.8337 34.3885 29.7546 34.3105L25.0074 29.6263C24.7698 29.3919 24.6649 29.0544 24.7276 28.7266L25.7083 23.6007C25.7882 23.1831 26.1233 22.8618 26.5438 22.7994C26.9643 22.737 27.3782 22.9473 27.5759 23.3237C28.0259 24.1807 28.4769 24.9133 28.9923 25.5138C29.6078 26.2309 30.3131 26.7584 31.2081 27.1079C32.0879 27.4516 33.113 27.6084 34.3486 27.6454C34.787 27.6586 35.1531 27.3138 35.1663 26.8754C35.1794 26.437 34.8347 26.0709 34.3962 26.0577C33.2568 26.0236 32.4319 25.8807 31.786 25.6284C31.1558 25.3822 30.66 25.0179 30.1976 24.4793C29.7224 23.9257 29.2798 23.1849 28.7725 22.1769C28.4111 21.4588 28.0366 20.6465 27.6035 19.7069L27.5979 19.6948C27.4172 19.3028 27.2256 18.8871 27.0185 18.4425C26.5887 17.5196 25.9671 16.7721 25.1573 16.3534C24.3296 15.9255 23.388 15.885 22.4363 16.2379Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );