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="M25.5044 10.1919C25.2116 9.68844 24.7943 9.30099 24.3137 9.04603C23.5959 8.66519 22.737 8.57991 21.9413 8.84493C21.9295 8.82227 21.9171 8.79977 21.9041 8.77745C21.458 8.01035 20.4723 7.74622 19.7024 8.18751L19.6463 8.21962L18.3771 6.04688L15.777 7.54398L17.0432 9.71166L16.8941 9.79713C16.1242 10.2384 15.8618 11.218 16.3079 11.9851C16.3454 12.0497 16.3868 12.1107 16.4316 12.168C15.6786 13.1012 15.537 14.4368 16.1774 15.538L16.8564 16.7057C13.959 18.3246 11.7286 20.2682 10.5011 22.7054C9.35823 24.9746 9.14192 27.5566 9.90342 30.4842C7.81695 32.3169 6.5 35.0047 6.5 38C6.5 39.4222 6.7969 40.7751 7.33209 42H39.5C40.0523 42 40.5 41.5523 40.5 41C40.5 40.4477 40.0523 40 39.5 40H26.3C26.4311 39.3538 26.5 38.6849 26.5 38C26.5 37.2293 26.4128 36.4791 26.2478 35.7584L17.7291 38.015L17.2049 36.085L25.6004 33.861L26.2499 35.75L38.0035 32.6464L37.4801 30.7162L25.6043 33.8574C24.0294 30.4019 20.5452 28 16.5 28C14.7478 28 13.1008 28.4507 11.6687 29.2424C11.2272 27.0311 11.4894 25.1893 12.2874 23.605C13.2715 21.651 15.1386 19.9516 17.8621 18.4349L20.7 23.3149C21.533 24.7471 23.3735 25.2403 24.8109 24.4164L25.5194 24.0103L26.2361 25.237L28.8367 23.7396L28.1231 22.5179L28.9325 22.054C29.0033 22.0134 29.0719 21.9703 29.1381 21.925C30.4151 21.0507 30.819 19.3305 30.0271 17.9688L25.5044 10.1919Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M31.5 6C29.4325 6 27.5116 6.6274 25.9173 7.7022C26.4358 8.09245 26.8867 8.59037 27.2333 9.18649L31.756 16.9634C32.3259 17.9434 32.5246 19.0355 32.3955 20.0779C32.4263 20.0923 32.4567 20.1084 32.4866 20.1263L34.1334 21.1118C34.6073 21.3953 34.7736 22.0164 34.5048 22.4988C34.2361 22.9813 33.634 23.1426 33.1601 22.859L31.7374 22.0076C31.4896 22.4262 31.1784 22.8118 30.8078 23.1488L31.5787 24.4685L29.3293 25.7638C30.0282 25.9184 30.7546 26 31.5 26C37.0228 26 41.5 21.5228 41.5 16C41.5 10.4772 37.0228 6 31.5 6ZM35.8056 16.0406C35.4222 15.6432 35.4222 14.9988 35.8056 14.6013L37.1502 13.2077C37.5337 12.8103 38.1554 12.8103 38.5389 13.2077C38.9224 13.6052 38.9224 14.2496 38.5389 14.647L37.1943 16.0406C36.8108 16.4381 36.1891 16.4381 35.8056 16.0406ZM32.5389 12.1131C32.1554 12.5106 31.5337 12.5106 31.1502 12.1131L29.8056 10.7195C29.4222 10.3221 29.4222 9.67767 29.8056 9.28022C30.1891 8.88277 30.8109 8.88277 31.1943 9.28022L32.5389 10.6738C32.9224 11.0713 32.9224 11.7157 32.5389 12.1131ZM32.8277 14.9128C33.3528 14.9128 33.7785 15.354 33.7785 15.8983C33.7785 16.4425 33.3528 16.8837 32.8277 16.8837C32.3026 16.8837 31.8769 16.4425 31.8769 15.8983C31.8769 15.354 32.3026 14.9128 32.8277 14.9128ZM35.2045 10.0291C35.7296 10.0291 36.1553 10.4703 36.1553 11.0145C36.1553 11.5587 35.7296 11.9999 35.2045 11.9999C34.6794 11.9999 34.2538 11.5587 34.2538 11.0145C34.2538 10.4703 34.6794 10.0291 35.2045 10.0291ZM36.1553 18.6082C36.6804 18.6082 37.1061 19.0494 37.1061 19.5936C37.1061 20.1378 36.6804 20.579 36.1553 20.579C35.6302 20.579 35.2046 20.1378 35.2046 19.5936C35.2046 19.0494 35.6302 18.6082 36.1553 18.6082Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );