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="M23 31.584C22.3875 31.8516 21.7111 32 21 32C18.2386 32 16 29.7614 16 27C16 24.2386 18.2386 22 21 22C21.7111 22 22.3875 22.1484 23 22.416V31.584Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.0052 4.89776C10.0564 4.3935 10.4822 4 11 4H21C21.5523 4 22 4.44772 22 5V8C22 8.55228 21.5523 9 21 9H20V11.2729C20.5826 11.4788 21 12.0344 21 12.6875V18C25.9706 18 30 22.0294 30 27C30 29.125 29.2635 31.078 28.032 32.6176L30.4822 35.0679C31.1494 34.8897 31.8908 35.0624 32.4142 35.5858L37.4142 40.5858C38.1953 41.3668 38.1953 42.6332 37.4142 43.4142C36.6332 44.1953 35.3668 44.1953 34.5858 43.4142L29.5858 38.4142C29.0623 37.8907 28.8897 37.1493 29.0679 36.482L26.6178 34.0318C25.0781 35.2635 23.125 36 21 36V39C21 39.6169 20.8883 40.2077 20.684 40.7533C19.9737 42.6499 18.1445 44 16 44C13.8555 44 12.0263 42.6499 11.316 40.7533C11.1117 40.2077 11 39.6169 11 39V12.6875C11 12.0344 11.4174 11.4788 12 11.2729V9H11C10.4477 9 10 8.55228 10 8V5C10 4.96548 10.0017 4.93137 10.0052 4.89776ZM17.3702 21.0134C18.4286 20.3703 19.6711 20 21 20C24.866 20 28 23.134 28 27C28 29.7924 26.3649 32.2029 24 33.3264C23.0907 33.7583 22.0736 34 21 34C19.067 34 17.317 33.2165 16.0503 31.9497C16.0344 31.9339 16.0186 31.918 16.003 31.902L16 31.899C14.7628 30.6364 14 28.9073 14 27C14 25.0927 14.7628 23.3636 16 22.101C16.4085 21.6842 16.8687 21.3182 17.3702 21.0134ZM19 13.1021C18.4174 12.8962 18 12.3406 18 11.6875V9H14V11.6875C14 12.3406 13.5826 12.8962 13 13.1021V18H19V13.1021Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );