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="M29.4157 10.598C29.2561 10.2347 28.8969 10 28.5 10H23V12H27.8469L29.603 16H27.7316C24.186 16 21.0297 18.0764 19.5815 21.2059L16.5517 18.2806C16.3653 18.1006 16.1163 18 15.8571 18H7C6.44771 18 6 18.4477 6 19V23C6 23.5523 6.44771 24 7 24H16.1707C16.0602 24.3128 16 24.6494 16 25C16 26.6569 17.3431 28 19 28H20.4116L21.8005 30.5H16.9236C16.4425 27.3849 13.7498 25 10.5 25C6.91015 25 4 27.9101 4 31.5C4 35.0899 6.91015 38 10.5 38C13.7498 38 16.4425 35.6151 16.9236 32.5H26.5C26.8011 32.5 27.0862 32.3643 27.2761 32.1306L33.3843 24.6129L34.0022 26.0204C32.1968 27.1752 31 29.1979 31 31.5C31 35.0899 33.9101 38 37.5 38C41.0899 38 44 35.0899 44 31.5C44 27.9101 41.0899 25 37.5 25C36.9238 25 36.3651 25.075 35.8332 25.2157L34.0953 21.2572L40.2135 22.1985L38.7849 13.6267L31.9067 16.2721L29.4157 10.598ZM22.6995 28L24.0884 30.5H26.024L31.3053 24H28V25C28 26.6569 26.6569 28 25 28H22.6995ZM25 26C25.5523 26 26 25.5523 26 25V24H19C18.4477 24 18 24.4477 18 25C18 25.5523 18.4477 26 19 26H25ZM27.7316 18C24.9932 18 22.5536 19.5934 21.4182 22H32.2371L30.4811 18H27.7316ZM32.7116 18.1054L33.1426 19.0871L37.7865 19.8015L37.2151 16.3733L32.7116 18.1054ZM10.5 27C12.6416 27 14.4338 28.496 14.8885 30.5H10.5C9.94772 30.5 9.5 30.9477 9.5 31.5C9.5 32.0523 9.94772 32.5 10.5 32.5H14.8885C14.4338 34.504 12.6416 36 10.5 36C8.01472 36 6 33.9853 6 31.5C6 29.0147 8.01472 27 10.5 27ZM33 31.5C33 30.0186 33.7159 28.7043 34.8205 27.8844L36.5843 31.902C36.8064 32.4077 37.3963 32.6377 37.902 32.4156C38.4077 32.1936 38.6376 31.6037 38.4156 31.098L36.6516 27.0799C36.9263 27.0274 37.21 27 37.5 27C39.9853 27 42 29.0147 42 31.5C42 33.9853 39.9853 36 37.5 36C35.0147 36 33 33.9853 33 31.5ZM15.4532 20L17.5246 22H8V20H15.4532Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );