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="M13.5 10.0968C13.5 7.77419 24 6 24 6C24 6 34.5 7.77419 34.5 10.0968C34.5 13.1939 32.5909 14.5 32.5909 14.5H15.4091C15.4091 14.5 13.5 13.1935 13.5 10.0968ZM25.5 10.5C25.5 11.3284 24.8284 12 24 12C23.1716 12 22.5 11.3284 22.5 10.5C22.5 9.67157 23.1716 9 24 9C24.8284 9 25.5 9.67157 25.5 10.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M31.8143 18.2794C33.2047 17.1955 32.9877 16 32.9877 16H15.0123C15.0123 16 14.7953 17.1955 16.1857 18.2794C16.064 18.8342 16 19.41 16 20C16 24.4183 19.5817 28 24 28C28.4183 28 32 24.4183 32 20C32 19.41 31.936 18.8342 31.8143 18.2794ZM24 20C26.7215 20 28.6235 19.6861 29.9517 19.234C29.9835 19.4846 30 19.7403 30 20C30 23.3137 27.3137 26 24 26C20.6863 26 18 23.3137 18 20C18 19.7403 18.0165 19.4846 18.0483 19.234C19.3765 19.6861 21.2785 20 24 20Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.5 30C26.0523 30 26.5 30.4477 26.5 31V32.382C26.5 32.7607 26.286 33.107 25.9472 33.2764L25.5 33.5L26.0769 36.3846L30.3172 30.0243C30.6067 30.0256 30.8761 30.0272 31.1214 30.029C36.5255 31.2619 42 33.7758 42 37.5576V42.0001H6V37.5576C6 33.7758 11.7135 31.2329 17.1176 30C17.0992 30.0043 17.3016 30.0073 17.6729 30.0094L21.9565 36.4348L22.5 33.5L22.0528 33.2764C21.714 33.107 21.5 32.7607 21.5 32.382V31C21.5 30.4477 21.9477 30 22.5 30H25.5ZM35 35.3333C35 35.3333 33.6667 34.6667 33 34C32.3333 34.6667 31 35.3333 31 35.3333C31 35.3333 31.6983 38 33 38C34.3017 38 35 35.3333 35 35.3333Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );