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="M38.972 25.1729L38.9824 25.1833L38.3716 25.6844C38.7377 25.3714 39.0622 25.011 39.3357 24.6128L38.972 25.1729ZM19.1925 17.1012L18.1023 18.8739L15.4444 13.495L14.6433 11.8739L13.6961 13.4142L10.6455 18.375H5V11H36.9515V12.1938C36.3198 12.0667 35.6662 12 34.9976 12C31.4727 12 28.3805 13.8505 26.6875 16.625H20.0443H19.4853L19.1925 17.1012ZM21.7189 20.625H25.3585C25.3317 20.9126 25.3181 21.2037 25.3181 21.4978C25.3181 26.7631 29.6718 30.9956 34.9976 30.9956C35.666 30.9956 36.3196 30.9288 36.9515 30.8016V33H21.9743H20.9772H20.9743H19.9772H5V22.375H12.32H12.879L13.1719 21.8988L14.262 20.1261L16.9199 25.505L17.6587 27H14.9857V26V24V23H13.9857H7.99429H6.99429V24V26V27V28V30V31H7.99429H19.9772H20.9772V30V28V27H19.9772H17.7986L18.6683 25.5858L21.7189 20.625ZM25.9692 37C25.9696 37 25.9696 37.0001 25.9693 37C25.9693 37 25.9692 37 25.9691 37L25.9692 37ZM25.9676 37.0001C25.9677 37.0002 25.9676 37.0002 25.9675 37L25.9676 37.0001ZM15.9829 37C15.9819 37 15.9817 36.9999 15.9822 37C15.9817 37.0001 15.9819 37 15.9829 37Z" fill="black" stroke="black" stroke-width="2"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );