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 10.5C20 12.9853 17.9853 15 15.5 15C13.0147 15 11 12.9853 11 10.5C11 8.01472 13.0147 6 15.5 6C17.9853 6 20 8.01472 20 10.5ZM18 10.5C18 11.8807 16.8807 13 15.5 13C14.1193 13 13 11.8807 13 10.5C13 9.11929 14.1193 8 15.5 8C16.8807 8 18 9.11929 18 10.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M37 10.5C37 12.9853 34.9852 15 32.5 15C30.0147 15 28 12.9853 28 10.5C28 8.01472 30.0147 6 32.5 6C34.9852 6 37 8.01472 37 10.5ZM35 10.5C35 11.8807 33.8807 13 32.5 13C31.1193 13 30 11.8807 30 10.5C30 9.11929 31.1193 8 32.5 8C33.8807 8 35 9.11929 35 10.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M36.1492 41.9955C37.4696 41.9166 38.5 40.8228 38.5 39.5V30.9584C38.6628 30.9858 38.8299 31 39 31C40.6568 31 42 29.6569 42 28C42 27.4789 41.9941 26.9959 41.9891 26.5908L41.9889 26.5797L41.9889 26.578L41.9889 26.5767L41.9846 26.2059C41.9819 25.9482 41.9814 25.7588 41.9827 25.6231C41.9833 25.5553 41.9843 25.5038 41.9856 25.4657C41.9857 25.461 41.9859 25.4566 41.986 25.4524C41.9865 25.44 41.987 25.4301 41.9874 25.4224L41.9877 25.4165L41.9882 25.4088L41.996 25.3206C41.9987 25.2912 42 25.2617 42 25.2321V25.1435C41.9999 23.0478 41.7505 20.9006 40.8214 19.1838C40.329 18.2739 39.619 17.4364 38.6297 16.8415C37.6384 16.2453 36.5448 16 35.4542 16H31.5458C28.1649 16 25.5886 18.2281 24 20.3043C22.4114 18.2281 19.8351 16 16.4542 16H12.5458C11.4552 16 10.3616 16.2453 9.37023 16.8415C8.381 17.4364 7.67098 18.2739 7.17857 19.1838C6.24949 20.9006 6.00002 23.0478 6 25.1435V25.2321C6 25.2617 6.00131 25.2912 6.00392 25.3206L6.01175 25.4087L6.0126 25.4224C6.01315 25.4327 6.01378 25.4468 6.01439 25.4657C6.01564 25.5038 6.01667 25.5553 6.0173 25.6231C6.01856 25.7588 6.01809 25.9482 6.01541 26.2059C6.01421 26.3209 6.01268 26.4454 6.01104 26.5787L6.01101 26.5805C6.006 26.9877 6 27.4745 6 28C6 29.6569 7.34315 31 9 31C9.17011 31 9.33718 30.9858 9.5 30.9584V39.5C9.5 40.827 10.5368 41.9228 11.8617 41.9962C13.1867 42.0696 14.3382 41.095 14.4847 39.7761L14.5 39.6385L14.5153 39.7761C14.6618 41.095 15.8133 42.0696 17.1383 41.9962C18.4632 41.9228 19.5 40.827 19.5 39.5L19.5 30.0227L19.7427 24.6838C20.1148 25.2763 20.4057 25.8748 20.6146 26.4195C20.8947 27.1499 21 27.7119 21 28C21 29.6569 22.3431 31 24 31C24.9691 31 25.8308 30.5405 26.3793 29.8275C26.7685 29.3215 27 28.6878 27 28C27 27.7119 27.1052 27.1499 27.3853 26.4195C27.5942 25.8748 27.8852 25.2763 28.2573 24.6838L28.5 30.0227V39.5C28.5 40.8228 29.5304 41.9166 30.8508 41.9955C32.1712 42.0745 33.3246 41.1112 33.4822 39.7979L33.5 39.6495L33.5178 39.7979C33.6754 41.1112 34.8288 42.0745 36.1492 41.9955ZM11.5 39.5C11.5 39.7654 11.7074 39.9846 11.9724 39.9992C12.2373 40.0139 12.4676 39.819 12.4969 39.5552L13.5061 30.4726C13.5624 29.9662 13.9905 29.5831 14.5 29.5831C15.0096 29.5831 15.4376 29.9662 15.4939 30.4726L16.5031 39.5552C16.5324 39.819 16.7627 40.0139 17.0276 39.9992C17.2926 39.9846 17.5 39.7654 17.5 39.5L17.5 30C17.5 29.9849 17.5003 29.9697 17.501 29.9546L17.8611 22.0341C17.8785 21.6514 18.113 21.3123 18.4649 21.1609C18.8168 21.0095 19.2243 21.0725 19.5141 21.3231C20.0321 21.771 20.5323 22.3253 21.0019 22.9754C21.6596 23.8859 22.1519 24.8425 22.482 25.7034C22.8045 26.5443 23 27.3663 23 28C23 28.5523 23.4477 29 24 29C24.5523 29 25 28.5523 25 28C25 26.2408 24.0568 23.7889 22.6232 21.8043C21.1952 19.8274 19.0482 18 16.4542 18H12.5458C11.757 18 11.0324 18.1757 10.401 18.5554C9.77026 18.9347 9.29111 19.4823 8.93751 20.1357C8.2491 21.4078 8.00002 23.1478 8 25.1435V25.1878L8.00392 25.232C8.01897 25.4014 8.02053 25.7244 8.0153 26.2267C8.01408 26.3439 8.01253 26.4699 8.0109 26.6025C8.00586 27.011 8 27.4876 8 28C8 28.5523 8.44772 29 9 29C9.1838 29 9.35321 28.9513 9.49928 28.8668L9.5 23H11.5L11.5 39.5ZM25.3768 21.8043C25.3095 21.8974 25.2433 21.9916 25.1782 22.0867C25.5723 22.7782 25.9196 23.5033 26.2025 24.234C26.4336 23.8138 26.6987 23.3898 26.998 22.9754C27.4676 22.3253 27.9678 21.771 28.4859 21.3231C28.7757 21.0725 29.1831 21.0095 29.5351 21.1609C29.887 21.3123 30.1215 21.6514 30.1389 22.0341L30.4989 29.9546C30.4996 29.9697 30.5 29.9849 30.5 30V39.5C30.5 39.7645 30.706 39.9833 30.9701 39.9991C31.2342 40.0149 31.4649 39.8222 31.4964 39.5596L32.5071 31.1372C32.5674 30.6346 32.9938 30.2563 33.5 30.2563C34.0062 30.2563 34.4325 30.6346 34.4928 31.1372L35.5035 39.5596C35.535 39.8222 35.7657 40.0149 36.0298 39.9991C36.2939 39.9833 36.5 39.7645 36.5 39.5V23H38.5V28.8664C38.646 28.9509 38.8162 29 39 29C39.5523 29 40 28.5523 40 28C40 27.4877 39.9941 27.0119 39.9891 26.6035L39.9891 26.6013L39.9889 26.5912C39.9873 26.4627 39.9859 26.3405 39.9847 26.2267C39.9794 25.7244 39.981 25.4014 39.996 25.232L40 25.1878V25.1435C39.9999 23.1478 39.7509 21.4078 39.0625 20.1357C38.7089 19.4823 38.2297 18.9347 37.599 18.5554C36.9676 18.1757 36.243 18 35.4542 18H31.5458C28.9518 18 26.8048 19.8274 25.3768 21.8043Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );