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.8469L32.5123 22.6267C32.4046 22.6868 32.3064 22.7679 32.2239 22.8694L26.024 30.5H24.0884L22.6995 28H25C26.6569 28 28 26.6569 28 25H17.5C16.6716 25 16 25.6716 16 26.5C16 27.3284 16.6716 28 17.5 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.2157L29.4157 10.598ZM10.5 28C12.0855 28 13.4248 29.0543 13.8551 30.5H10.5C9.94771 30.5 9.5 30.9477 9.5 31.5C9.5 32.0523 9.94771 32.5 10.5 32.5H13.8551C13.4248 33.9457 12.0855 35 10.5 35C8.567 35 7 33.433 7 31.5C7 29.567 8.567 28 10.5 28ZM34 31.5C34 30.4303 34.4798 29.4728 35.236 28.8308L36.5843 31.902C36.8064 32.4077 37.3963 32.6377 37.902 32.4156C38.4077 32.1936 38.6376 31.6037 38.4156 31.098L37.0672 28.0265C37.209 28.009 37.3534 28 37.5 28C39.433 28 41 29.567 41 31.5C41 33.433 39.433 35 37.5 35C35.567 35 34 33.433 34 31.5Z" fill="black"/>
<path d="M28.0259 17.0518C28.01 17.0201 27.9776 17 27.9421 17H23.6847C20.5432 17 18.2381 19.9523 19 23H29.3819C30.1253 23 30.6088 22.2177 30.2764 21.5528L28.0259 17.0518Z" fill="black"/>
<path d="M7 18C6.44772 18 6 18.4477 6 19V22C6 22.5523 6.44772 23 7 23H16.4194C17.2579 23 17.7241 22.0301 17.2002 21.3753L16.0012 19.8765C15.0524 18.6904 13.6158 18 12.0969 18H7Z" fill="black"/>
<path d="M34 16.5L40.0667 14L41 20L34.9333 19L34 16.5Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );