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 40C32.8366 40 40 32.8366 40 24C40 15.1634 32.8366 8 24 8C15.1634 8 8 15.1634 8 24C8 32.8366 15.1634 40 24 40ZM24 42C33.9411 42 42 33.9411 42 24C42 14.0589 33.9411 6 24 6C14.0589 6 6 14.0589 6 24C6 33.9411 14.0589 42 24 42Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M16.6949 28C18.25 31.8319 21.1142 34 24 34C26.8858 34 29.75 31.8319 31.3051 28H16.6949ZM24 36C19.9619 36 16.4618 32.9521 14.7419 28.5C14.7254 28.4572 14.709 28.4143 14.6928 28.3713C14.2445 27.18 15.1998 26 16.4727 26H31.5273C32.8002 26 33.7555 27.18 33.3072 28.3713C33.291 28.4143 33.2746 28.4572 33.2581 28.5C31.5382 32.9521 28.0381 36 24 36Z" fill="black"/>
<path d="M21.3023 22.4421C21.4323 22.0844 21.3934 21.6474 21.2857 21.2489C21.1734 20.8333 20.9666 20.3855 20.6753 19.9696C20.0947 19.1404 19.1318 18.3781 17.831 18.3234C16.4842 18.2669 15.4778 19.1216 14.8578 20.0288C14.5433 20.4891 14.3095 20.987 14.1629 21.4451C14.0202 21.8907 13.9445 22.3469 13.9944 22.7115C14.0175 22.8807 14.1254 23.0264 14.2804 23.0978C14.4355 23.1693 14.6163 23.1567 14.7599 23.0645C15.1593 22.8081 15.579 22.4572 15.9668 22.133C16.1434 21.9853 16.3135 21.8432 16.4719 21.7181C17.0342 21.274 17.4717 21.0209 17.8345 21.0032C18.1791 20.9863 18.5774 21.1839 19.0791 21.5592C19.2585 21.6935 19.4326 21.8355 19.6129 21.9827C19.6772 22.0351 19.7422 22.0882 19.8085 22.1417C20.0523 22.3386 20.3119 22.5409 20.5736 22.6991C20.7016 22.7766 20.8576 22.7926 20.9987 22.7429C21.1398 22.6931 21.2512 22.5827 21.3023 22.4421Z" fill="black"/>
<path d="M26.6132 22.4421C26.4832 22.0844 26.5221 21.6474 26.6298 21.2489C26.7421 20.8333 26.9489 20.3855 27.2402 19.9696C27.8208 19.1404 28.7838 18.3781 30.0845 18.3234C31.4313 18.2669 32.4377 19.1216 33.0577 20.0288C33.3723 20.4891 33.606 20.987 33.7527 21.4451C33.8954 21.8907 33.971 22.3469 33.9211 22.7115C33.898 22.8807 33.7901 23.0264 33.6351 23.0978C33.4801 23.1693 33.2993 23.1567 33.1556 23.0645C32.7563 22.8081 32.3365 22.4572 31.9487 22.133C31.7721 21.9853 31.602 21.8432 31.4436 21.7181C30.8813 21.274 30.4438 21.0209 30.081 21.0032C29.7365 20.9863 29.3381 21.1839 28.8365 21.5592C28.6571 21.6935 28.483 21.8355 28.3026 21.9827C28.2384 22.0351 28.1733 22.0882 28.107 22.1417C27.8632 22.3386 27.6036 22.5409 27.342 22.6991C27.2139 22.7766 27.058 22.7926 26.9169 22.7429C26.7758 22.6931 26.6644 22.5827 26.6132 22.4421Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );