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 d="M34.5 6L32.3333 13.6905L28 15.9524L32.3333 18.2143L34.5 25L36.6667 18.2143L41 15.9524L36.6667 13.6905L34.5 6Z" fill="black"/>
<path d="M20 12L19 16L16 17L19 18L20 22L21 18L24 17L21 16L20 12Z" fill="black"/>
<path d="M6 30.0007C6 29.4484 6.44772 29.0007 7 29.0007H10C10.5523 29.0007 11 29.4484 11 30.0007V40.9961C11 41.5484 10.5523 41.9961 10 41.9961H7C6.44772 41.9961 6 41.5484 6 40.9961V30.0007Z" fill="black"/>
<path d="M17.7052 29.1888C18.6371 28.764 20.9148 29.1888 20.9148 29.1888L27.541 30.6755C27.541 30.6755 29.1976 31.2065 30.7506 31.2065C32.3037 31.2065 31.3753 33.3318 30.3365 34.0738C29.2977 34.8159 28.542 34.7757 28.542 34.7757L23.1926 34.711C23.1926 34.711 27.8517 35.5606 29.6117 35.6668C30.5034 35.7206 32.0326 35.0931 33.7419 34.3917C35.4069 33.7085 37.2426 32.9553 38.8263 32.6933C42.0359 32.1623 42.5536 35.0296 41.5182 36.0915C40.4829 37.1535 32.2001 41.1889 30.7506 41.7199C29.6155 42.1358 28.2424 41.9977 26.6931 41.842C26.2641 41.7989 25.8215 41.7544 25.3668 41.7199C23.5575 41.5828 22.1749 41.1433 20.8062 40.7081C19.3391 40.2418 17.8882 39.7805 15.9451 39.7022C15.2933 39.6759 13.7674 39.7566 13 39.8015L13 30.941C14.3259 30.4693 17.0113 29.5051 17.7052 29.1888Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );