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="M42.1198 16.1733L43.9264 20.6238L42.0733 21.3761L40.4088 17.2755L30.9957 18.0673C30.958 21.8374 30.6493 25.4395 29.1093 28.1602C28.2568 29.6662 27.0335 30.8958 25.3166 31.7374C23.6149 32.5716 21.4795 33 18.8268 33C13.7179 33 11.0172 32.8968 9.58385 32.7909C8.86948 32.7381 8.44754 32.6832 8.18921 32.6344C8.06047 32.6101 7.95196 32.5836 7.85846 32.5518C7.8108 32.5356 7.75673 32.5146 7.70033 32.4864C7.67156 32.472 7.63935 32.4544 7.60529 32.4328C7.58812 32.4219 7.56996 32.4096 7.55114 32.3959C7.54171 32.3891 7.53204 32.3818 7.52218 32.374L7.50723 32.3621L7.49963 32.3558C7.49578 32.3526 7.49196 32.3493 8.13944 31.5873C7.20158 31.9343 7.20096 31.9326 7.20096 31.9326L7.20022 31.9306L7.19837 31.9255L7.19331 31.9114C7.18934 31.9002 7.18421 31.8855 7.17806 31.8674C7.16577 31.8313 7.14941 31.7814 7.13016 31.7188C7.09171 31.5936 7.04161 31.4169 6.98958 31.1959C6.88572 30.7549 6.7729 30.1321 6.73112 29.3868C6.64764 27.8978 6.84667 25.8871 8.00004 23.8702C9.74411 20.8204 13.4985 18.0189 21 16.795V14C21 13.4477 21.4477 13 22 13C22.5523 13 23 13.4477 23 14V16.5174C25.066 16.2778 27.3821 16.1468 29.9767 16.146L40.3044 15.2773L42.0453 9.7019L43.9544 10.298L42.1198 16.1733ZM8.93291 30.7229C8.85169 30.3748 8.76162 29.8749 8.72798 29.2748C8.70611 28.8847 8.70817 28.4555 8.75099 28H19.92C20.3282 28 20.6246 27.799 20.7939 27.6424C20.964 27.485 21.0878 27.2994 21.1775 27.1415C21.3588 26.8223 21.5099 26.4177 21.639 26.0009C21.9016 25.1528 22.1377 24.0372 22.3351 22.9063C22.6026 21.3739 22.8143 19.7216 22.922 18.5393C24.7126 18.3196 26.7275 18.1838 28.9943 18.1528C28.9499 21.8571 28.6275 24.9512 27.3688 27.175C26.7032 28.3509 25.7707 29.2875 24.4363 29.9416C23.0866 30.6032 21.275 31 18.8268 31C13.7342 31 11.0911 30.8968 9.73121 30.7964C9.38167 30.7705 9.12273 30.7453 8.93291 30.7229ZM20.8831 18.8411C14.0718 20.0349 11.0485 22.5682 9.7362 24.8631C9.51867 25.2434 9.34365 25.6242 9.20416 26H19.5146C19.5765 25.8605 19.6492 25.6654 19.7285 25.4093C19.9534 24.6831 20.1723 23.6659 20.3649 22.5624C20.5939 21.2504 20.774 19.8866 20.8831 18.8411Z" fill="black"/>
<path d="M8.13944 31.5873L7.49196 32.3493C7.36115 32.2382 7.26115 32.0953 7.20158 31.9343L8.13944 31.5873Z" fill="black"/>
<path d="M5 10C4.44772 10 4 10.4477 4 11C4 11.5523 4.44772 12 5 12H38.0048C38.5571 12 39.0048 11.5523 39.0048 11C39.0048 10.4477 38.5571 10 38.0048 10H5Z" fill="black"/>
<path d="M4.37534 34.2192C4.8066 33.8742 5.4359 33.9441 5.78091 34.3753C6.00179 34.6514 6.56429 34.9759 7.539 35.2553C8.46309 35.5202 9.57632 35.6956 10.6741 35.8089C11.7656 35.9215 12.8098 35.9695 13.5835 35.9892C13.9695 35.999 14.2861 36.0017 14.5052 36.002C14.6147 36.0021 14.6997 36.0017 14.7566 36.0012L14.8205 36.0005L14.8358 36.0003L14.8392 36.0002L14.8484 36H30.5C31.0523 36 31.5 36.4478 31.5 37C31.5 37.5523 31.0523 38 30.5 38H14.865L14.847 38.0003L14.774 38.0011C14.7109 38.0016 14.6192 38.0021 14.5027 38.002C14.2698 38.0017 13.9368 37.9988 13.5327 37.9886C12.726 37.968 11.6273 37.9179 10.4688 37.7983C9.31661 37.6794 8.0727 37.4888 6.98786 37.1778C5.95364 36.8814 4.85543 36.4201 4.21917 35.6247C3.87416 35.1935 3.94408 34.5642 4.37534 34.2192Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );