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 d="M38.2141 31.3529C39.3553 29.1513 40 26.6509 40 24C40 15.1634 32.8366 8 24 8C15.1634 8 8 15.1634 8 24C8 26.651 8.6447 29.1513 9.78587 31.3529L8.73034 33.5354C7.00013 30.7706 6 27.5021 6 24C6 14.0589 14.0589 6 24 6C33.9411 6 42 14.0589 42 24C42 27.5021 40.9999 30.7706 39.2697 33.5354L38.2141 31.3529Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 17C21.2386 17 19 19.2386 19 22C19 24.7614 21.2386 27 24 27C26.7614 27 29 24.7614 29 22C29 19.2386 26.7614 17 24 17ZM21 22C21 20.3431 22.3431 19 24 19C25.6569 19 27 20.3431 27 22C27 23.6569 25.6569 25 24 25C22.3431 25 21 23.6569 21 22Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.0583 25.2531C14.0997 25.155 14.1447 25.0593 14.1932 24.9659C14.0665 24.3303 14 23.6729 14 23C14 17.4772 18.4772 13 24 13C29.5228 13 34 17.4772 34 23C34 23.6728 33.9335 24.3302 33.8069 24.9657C33.8553 25.0592 33.9004 25.155 33.9418 25.2531L38.6689 36.4438C39.7828 39.0808 37.8468 42.0002 34.9841 42.0002H31.5668C31.5235 42.001 31.4802 42.001 31.4371 42.0002H16.563C16.5198 42.001 16.4765 42.001 16.4332 42.0002H13.016C10.1533 42.0002 8.2173 39.0808 9.33122 36.4438L14.0583 25.2531ZM24 15C19.5817 15 16 18.5817 16 23C16 23.0695 16.0009 23.1388 16.0027 23.2079C16.4666 22.9836 16.9766 22.8476 17.5076 22.8165C17.5411 23.5155 17.685 24.1855 17.9223 24.8096H17.743C16.9392 24.8096 16.2134 25.2908 15.9006 26.0313L11.1736 37.222C10.6166 38.5405 11.5846 40.0002 13.016 40.0002H13.3378C12.9228 39.1246 12.8713 38.0819 13.283 37.1212L15.7637 31.3334C16.6304 29.3112 18.6188 28 20.8189 28H27.181C29.3812 28 31.3696 29.3112 32.2363 31.3334L34.7169 37.1212C35.1286 38.0819 35.0772 39.1246 34.6622 40.0002H34.9841C36.4155 40.0002 37.3835 38.5405 36.8265 37.222L32.0995 26.0313C31.7867 25.2908 31.0609 24.8096 30.2571 24.8096H30.0777C30.315 24.1855 30.4589 23.5155 30.4925 22.8165C31.0235 22.8476 31.5334 22.9836 31.9974 23.2079C31.9991 23.1388 32 23.0695 32 23C32 18.5817 28.4183 15 24 15ZM32.0908 39.8787C31.9066 39.9577 31.7151 39.997 31.5259 40.0002H31.4747C31.1182 39.9941 30.7734 39.8604 30.5053 39.6236C30.4692 39.5917 30.4312 39.5628 30.3918 39.5369L28.4285 34.6286C28.2234 34.1158 27.6414 33.8664 27.1286 34.0715C26.6158 34.2766 26.3664 34.8586 26.5715 35.3714L28.423 40H19.577L21.4285 35.3714C21.6336 34.8586 21.3842 34.2766 20.8714 34.0715C20.3586 33.8664 19.7766 34.1158 19.5715 34.6286L17.6083 39.5368C17.5688 39.5627 17.5309 39.5916 17.4947 39.6235C17.2266 39.8604 16.8817 39.9941 16.5252 40.0002H16.4741C16.285 39.997 16.0934 39.9577 15.9091 39.8787C15.1477 39.5524 14.795 38.6705 15.1213 37.9091L17.6019 32.1212C18.1535 30.8344 19.4188 30 20.8189 30H27.181C28.5811 30 29.8465 30.8344 30.398 32.1212L32.8787 37.9091C33.205 38.6705 32.8523 39.5524 32.0908 39.8787Z" fill="black"/>
<path d="M19.3762 12.3814C20.8363 11.7886 22.3989 11.4892 23.9747 11.5003C25.5505 11.5114 27.1087 11.8327 28.5604 12.446L29.3387 10.6037C27.6451 9.88819 25.8272 9.51327 23.9888 9.50035C22.1503 9.48742 20.3273 9.83673 18.6238 10.5283L19.3762 12.3814Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );