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="M20.2846 6.40489C23.5474 5.70125 26.9407 5.91779 30.0886 7.0306C32.5038 7.88436 34.7024 9.2402 36.5453 11H31.5127C30.7405 10.9994 29.9983 11.2737 29.4033 11.7669C28.8094 12.2592 28.3971 12.9404 28.2193 13.694L27.0265 18.7713C26.9002 19.3089 27.2336 19.8472 27.7713 19.9735C28.3089 20.0998 28.8472 19.7664 28.9735 19.2287L30.1662 14.1521C30.2478 13.8063 30.4331 13.5111 30.6797 13.3067C30.9251 13.1032 31.218 12.9997 31.5112 13L38 13C38.1087 13 38.2134 12.9827 38.3113 12.9506C40.3061 15.504 41.5839 18.5495 42.0086 21.7707C42.0808 22.3183 42.5831 22.7036 43.1307 22.6314C43.6782 22.5592 44.0636 22.0569 43.9914 21.5093C43.5054 17.8221 42.0118 14.3415 39.6758 11.4531C37.3398 8.5647 34.2523 6.38121 30.7552 5.14496C27.2581 3.90869 23.4881 3.66807 19.863 4.44983C16.2378 5.23159 12.8995 7.0051 10.2176 9.57346C7.53564 12.1418 5.61478 15.4047 4.66726 19.0005C3.71974 22.5964 3.78242 26.3852 4.84838 29.9475C5.91434 33.5098 7.94211 36.7069 10.7076 39.1845C13.473 41.6622 16.8683 43.3235 20.5173 43.984C21.0607 44.0824 21.581 43.7216 21.6794 43.1781C21.7778 42.6347 21.417 42.1144 20.8735 42.016C18.3488 41.559 15.9585 40.5696 13.8567 39.1229L15.4085 31.313H16.4329C16.9755 31.3132 17.5107 31.189 17.998 30.9501C18.4853 30.7112 18.9116 30.364 19.2448 29.9352C19.578 29.5066 19.8094 29.0076 19.9219 28.4762C20.0345 27.9449 20.0252 27.3949 19.895 26.8676L18.6116 21.7053L18.6109 21.7024C18.4165 20.9302 17.971 20.2443 17.3438 19.7543C16.7168 19.2644 15.9444 18.9985 15.1489 19H6.74363C7.63948 15.9618 9.313 13.2089 11.6009 11.0179C14.0161 8.705 17.0217 7.10853 20.2846 6.40489ZM6.2747 21C5.78559 23.7845 5.95011 26.6528 6.76444 29.3741C7.72491 32.5839 9.55174 35.4638 12.0421 37.6949L12.0924 37.7398L13.6068 30.1181C13.6998 29.6501 14.1105 29.313 14.5876 29.313H16.4329C16.6698 29.3131 16.9042 29.2589 17.1176 29.1543C17.331 29.0497 17.5186 28.8972 17.6656 28.7079C17.8127 28.5187 17.9154 28.2978 17.9653 28.0618C18.0153 27.8261 18.0112 27.582 17.9535 27.3481L16.6714 22.1908L16.6711 22.1893C16.5846 21.8472 16.3875 21.5452 16.1124 21.3302C15.8371 21.1151 15.4991 20.9992 15.1521 21L6.2747 21Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.6777 33C24.8379 34.0213 25.2397 34.9624 25.8227 35.7631L24.7 36.8858L24.5071 36.6929C24.1166 36.3024 23.4834 36.3024 23.0929 36.6929C22.7024 37.0834 22.7024 37.7166 23.0929 38.1071L24.8929 39.9071C25.2834 40.2976 25.9166 40.2976 26.3071 39.9071C26.6976 39.5166 26.6976 38.8834 26.3071 38.4929L26.1142 38.3L27.2369 37.1773C28.0376 37.7603 28.9787 38.1621 30 38.3223V40.0049C29.4947 40.0551 29.1 40.4815 29.1 41C29.1 41.5523 29.5477 42 30.1 42H31.9C32.4523 42 32.9 41.5523 32.9 41C32.9 40.4815 32.5053 40.0551 32 40.0049V38.3223C33.2416 38.1275 34.3647 37.5757 35.2611 36.7753L36.7858 38.3L36.5929 38.4929C36.2024 38.8834 36.2024 39.5166 36.5929 39.9071C36.9834 40.2976 37.6166 40.2976 38.0071 39.9071L39.8071 38.1071C40.1976 37.7166 40.1976 37.0834 39.8071 36.6929C39.4166 36.3024 38.7834 36.3024 38.3929 36.6929L38.2 36.8858L36.5329 35.2187C36.9244 34.5473 37.1971 33.7981 37.3223 33H39.0049C39.0551 33.5053 39.4815 33.9 40 33.9C40.5523 33.9 41 33.4523 41 32.9V31.1C41 30.5477 40.5523 30.1 40 30.1C39.4815 30.1 39.0551 30.4947 39.0049 31H37.3223C37.1621 29.9787 36.7603 29.0376 36.1773 28.2369L37.3 27.1142L37.4929 27.3071C37.8834 27.6976 38.5166 27.6976 38.9071 27.3071C39.2976 26.9166 39.2976 26.2834 38.9071 25.8929L37.1071 24.0929C36.7166 23.7024 36.0834 23.7024 35.6929 24.0929C35.3024 24.4834 35.3024 25.1166 35.6929 25.5071L35.8858 25.7L34.7631 26.8227C33.9624 26.2397 33.0213 25.8379 32 25.6777V23.9951C32.5053 23.9449 32.9 23.5185 32.9 23C32.9 22.4477 32.4523 22 31.9 22H30.1C29.5477 22 29.1 22.4477 29.1 23C29.1 23.5185 29.4947 23.9449 30 23.9951V25.6777C28.9787 25.8379 28.0376 26.2397 27.2369 26.8227L26.1142 25.7L26.3071 25.5071C26.6976 25.1166 26.6976 24.4834 26.3071 24.0929C25.9166 23.7024 25.2834 23.7024 24.8929 24.0929L23.0929 25.8929C22.7024 26.2834 22.7024 26.9166 23.0929 27.3071C23.4834 27.6976 24.1166 27.6976 24.5071 27.3071L24.7 27.1142L25.8227 28.2369C25.2397 29.0376 24.8379 29.9787 24.6777 31H22.9951C22.9449 30.4947 22.5185 30.1 22 30.1C21.4477 30.1 21 30.5477 21 31.1V32.9C21 33.4523 21.4477 33.9 22 33.9C22.5185 33.9 22.9449 33.5053 22.9951 33H24.6777ZM26.6 32C26.6 29.5699 28.5699 27.6 31 27.6C33.4301 27.6 35.4 29.5699 35.4 32C35.4 34.4301 33.4301 36.4 31 36.4C28.5699 36.4 26.6 34.4301 26.6 32Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );