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="M6 23V33L12.4058 33C12.8174 33 13.228 32.9789 13.6361 32.9368C13.8654 31.0804 14 28.8754 14 26.5C14 25.2804 13.9645 24.1057 13.899 23H6Z" fill="black"/>
<path d="M17.2288 17.2689C17.5584 18.9172 17.7961 20.9515 17.9145 23.1973C18.2123 23.252 18.5081 23.318 18.8014 23.3951L21.1 24L21.1897 23.8489C22.6636 21.3666 24.9831 19.4987 27.7227 18.5881L32.5 17V14.8475C32.5 13.9733 32.7864 13.1232 33.3154 12.4272L36.3 8.50004L36.6755 8.82611C37.445 9.4944 37.5889 10.6345 37.0096 11.473L36.3 12.5L38.2 11L39.0614 9.18665C39.5931 8.06717 41.0273 7.73209 42 8.50004L41.05 15.5L36.3 18.5L31.5711 24.5445C30.3113 26.1548 28.6609 27.4165 26.7766 28.2099L24.9 29L24.1828 29.755C23.4276 30.55 22.3792 31 21.2828 31H20.15L17.7699 31.8352C17.639 33.2788 17.4557 34.5964 17.2288 35.7311C16.9895 36.9276 16.6815 38.0256 16.281 38.8726C16.0832 39.2911 15.8132 39.756 15.434 40.144C15.0515 40.5353 14.3998 41 13.4999 41C12.5999 41 11.9482 40.5353 11.5657 40.144C11.1865 39.756 10.9165 39.2911 10.7187 38.8726C10.3182 38.0256 10.0102 36.9276 9.77092 35.7311C9.72373 35.4951 9.67842 35.2512 9.63508 34.9999L11.6668 34.9999C12.1234 37.4603 12.7756 39 13.4999 39C14.8806 39 15.9999 33.4036 15.9999 26.5C15.9999 19.5964 14.8806 14 13.4999 14C12.8795 14 12.312 15.1297 11.875 17H14.5L11 21L7 17H9.82624C10.0572 15.9082 10.3484 14.9105 10.7187 14.1274C10.9165 13.7089 11.1865 13.244 11.5657 12.856C11.9482 12.4647 12.5999 12 13.4998 12C14.3998 12 15.0515 12.4647 15.434 12.856C15.8132 13.244 16.0832 13.7089 16.281 14.1274C16.6815 14.9744 16.9895 16.0724 17.2288 17.2689Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );