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="M24 6C24.5523 6 25 6.44772 25 7V7.06806C27.7982 7.36017 29.9335 8.5626 31.3234 10.0944C32.2785 11.1471 32.912 12.4024 33.1107 13.6255L33.219 13.7094C34.3431 14.5801 35.1677 15.6359 34.9723 16.8468C34.7835 18.0167 33.7264 18.7289 32.7424 19.1644C32.5054 19.2693 32.2512 19.3677 31.982 19.4596C31.9939 19.6383 32 19.8185 32 20C32 24.4183 28.4183 28 24 28C19.5817 28 16 24.4183 16 20C16 19.8185 16.0061 19.6383 16.018 19.4596C15.7488 19.3677 15.4946 19.2693 15.2576 19.1644C14.2736 18.7289 13.2165 18.0167 13.0277 16.8468C12.8323 15.6359 13.6569 14.5801 14.781 13.7094L14.9075 13.6115C14.9331 13.4532 14.9654 13.2949 15.0037 13.1374C15.235 12.1859 15.7048 11.1898 16.4154 10.2843C17.7556 8.57632 19.9483 7.19621 23 7.0192V7C23 6.44772 23.4477 6 24 6ZM31.6599 16.4404C32.0901 16.596 32.5573 16.4382 32.8118 16.0842C33.009 16.3594 33.0015 16.5054 32.9978 16.5282C32.9849 16.6083 32.8317 16.9378 31.9329 17.3356C30.8843 17.7997 29.3063 18.1368 27.4957 18.3255C27.4048 16.4736 25.8745 15 24 15C22.1255 15 20.5952 16.4736 20.5043 18.3255C18.6937 18.1368 17.1157 17.7997 16.0671 17.3356C15.1684 16.9378 15.0151 16.6083 15.0022 16.5282C14.9985 16.5054 14.991 16.3595 15.1881 16.0844C15.4443 16.4407 15.9158 16.5976 16.3473 16.4377C16.8652 16.2459 17.1295 15.6705 16.9376 15.1526C16.8177 14.8289 16.7812 14.2918 16.947 13.61C17.1092 12.9432 17.45 12.2057 17.9888 11.519L18 11.5047V13.5C18 14.0523 18.4477 14.5 19 14.5C19.5523 14.5 20 14.0523 20 13.5V9.84609C20.8216 9.41109 21.8166 9.10703 23 9.02329V11.5C23 12.0523 23.4477 12.5 24 12.5C24.5523 12.5 25 12.0523 25 11.5V9.081C26.1693 9.22751 27.1683 9.56343 28 10.0115V13.5C28 14.0523 28.4477 14.5 29 14.5C29.5523 14.5 30 14.0523 30 13.5V11.619C31.1155 12.9459 31.3524 14.35 31.0595 15.16C30.8717 15.6793 31.1405 16.2526 31.6599 16.4404ZM21.4668 20.9152C20.2526 20.8323 19.0787 20.6882 18.0189 20.4803C18.2636 23.5694 20.848 26 24 26C27.152 26 29.7364 23.5694 29.9811 20.4803C28.9213 20.6882 27.7474 20.8323 26.5332 20.9152C25.8958 21.5835 24.9965 22 24 22C23.0035 22 22.1042 21.5835 21.4668 20.9152ZM25.5 18.5C25.5 19.3284 24.8284 20 24 20C23.1716 20 22.5 19.3284 22.5 18.5C22.5 17.6716 23.1716 17 24 17C24.8284 17 25.5 17.6716 25.5 18.5Z" fill="black"/>
<path d="M24 39C25.1046 39 26 38.1046 26 37C26 35.8954 25.1046 35 24 35C22.8954 35 22 35.8954 22 37C22 38.1046 22.8954 39 24 39Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.5337 28.4003L23 31L25 31L28.4663 28.4003C34.5613 29.3764 42 32.0895 42 36.0001V42.0001H6V36.0001C6 32.0895 13.4387 29.3764 19.5337 28.4003ZM25.6667 33L28.9769 30.5173C29.9801 30.7015 31.0013 30.9315 32 31.203V40H34V31.8151C34.6994 32.0554 35.3715 32.3165 36 32.5967V40.0001H12V32.5967C12.6286 32.3165 13.3006 32.0554 14 31.8151V40H16V31.203C16.9987 30.9315 18.0199 30.7015 19.0231 30.5173L22.3333 33L25.6667 33ZM39.3048 34.6905C39.8693 35.2741 40 35.7049 40 36.0001V40.0001H38V33.6563C38.5391 34.0024 38.9757 34.3501 39.3048 34.6905ZM8.69515 34.6905C9.02434 34.3501 9.46091 34.0024 10 33.6563V40.0001H8V36.0001C8 35.7049 8.13075 35.2741 8.69515 34.6905Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );