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="M21.7372 10.3243L21.2275 9.76831L19.4971 10.6335L18.5683 11.2527C17.0071 10.4539 15.2387 10.0665 13.5009 10.0703C11.0758 10.0757 8.62119 10.8437 6.79868 12.4357C4.9492 14.0514 3.81954 16.4593 4.00187 19.5589L5.99842 19.4414C5.85133 16.9408 6.74446 15.1387 8.11446 13.942C9.51143 12.7216 11.473 12.0748 13.5053 12.0703C15.5363 12.0659 17.5487 12.7036 19.0346 13.9364C20.4973 15.1498 21.5001 16.9774 21.5001 19.5002C21.5001 22.5405 19.9244 24.1592 18.0952 25.7445C17.9503 25.87 17.8016 25.9971 17.6507 26.126L17.6494 26.1272C16.8749 26.7889 16.0451 27.4979 15.3981 28.2888C14.5889 29.2778 14.0002 30.463 14.0002 32.0002C14.0002 34.0923 13.2112 35.2325 12.3003 35.7778C11.3477 36.348 10.0563 36.3939 8.85178 35.8836C7.66105 35.3792 6.63391 34.3599 6.21398 32.9166C5.79625 31.4808 5.94294 29.4908 7.36839 26.9963L5.63191 26.004C4.00612 28.8491 3.6897 31.3996 4.29361 33.4753C4.89532 35.5434 6.37459 37.0063 8.07167 37.7252C9.75497 38.4383 11.7327 38.4484 13.3275 37.4938C14.9638 36.5144 16.0002 34.6408 16.0002 32.0002C16.0002 31.0373 16.3489 30.2851 16.946 29.5553C17.4696 28.9152 18.1355 28.3449 18.9084 27.683C19.0694 27.5451 19.2351 27.4032 19.4051 27.2558C19.6216 27.0682 19.8414 26.8746 20.0609 26.6731L20.5975 27.0727L20.5762 27.0967L21.3492 27.7593C22.2511 28.5323 23.0733 29.0878 23.8894 29.321C24.7864 29.5773 25.5829 29.4203 26.3195 28.987C26.9897 28.5928 27.6258 27.9593 28.2817 27.2648C28.4851 27.0495 28.6939 26.8243 28.9126 26.5883C29.1887 26.2904 29.4811 25.975 29.7981 25.6412C30.8985 26.2527 32.3132 26.0912 33.2477 25.1568L35.6666 22.7378C35.6976 22.7469 35.7287 22.7558 35.7599 22.7645C36.3137 22.918 36.8973 23 37.5 23C41.0899 23 44 20.0899 44 16.5C44 12.9101 41.0899 10 37.5 10C33.9101 10 31 12.9101 31 16.5C31 17.3109 31.1485 18.0871 31.4197 18.8029L29.1568 21.0659C28.3321 21.8906 28.1094 23.0894 28.4889 24.1161C28.0966 24.5265 27.7406 24.9104 27.4186 25.2577C27.2072 25.4858 27.0104 25.6981 26.8277 25.8916C26.1555 26.6033 25.6978 27.0324 25.3055 27.2631C24.9797 27.4548 24.7449 27.4854 24.4388 27.3979C24.1845 27.3253 23.8586 27.1624 23.4245 26.8531C25.1334 24.6651 26.1243 22.208 26.0622 19.5393C25.9925 16.5405 24.5971 13.4442 21.7372 10.3243ZM34.8631 15.5918C34.5748 15.7297 34.3047 15.918 34.0659 16.1568L33.0498 17.1729C33.017 16.9536 33 16.7289 33 16.5C33 14.0147 35.0147 12 37.5 12C39.9853 12 42 14.0147 42 16.5C42 18.9771 39.9985 20.9868 37.5244 20.9999L38.2992 20.2252C39.4377 19.0867 39.4377 17.2407 38.2992 16.1022C37.3688 15.1719 35.9661 15.0017 34.8631 15.5918ZM32.4538 20.5973L30.571 22.4801C30.2224 22.8287 30.2224 23.3939 30.571 23.7425C30.9196 24.0912 31.4849 24.0912 31.8335 23.7425L36.7426 18.8335C37.0912 18.4848 37.0912 17.9196 36.7426 17.571C36.4788 17.3072 36.091 17.243 35.7669 17.3784C35.704 17.4162 35.6446 17.4622 35.5904 17.5164L32.4788 20.628C32.4704 20.6178 32.4621 20.6076 32.4538 20.5973Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );