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="M21 20.1319C21.4869 20.0452 21.9882 20 22.5 20C27.1944 20 31 23.8056 31 28.5C31 30.4869 30.3183 32.3145 29.176 33.7618L30.4821 35.0679C31.1493 34.8897 31.8908 35.0623 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.8908 28.8897 37.1493 29.0679 36.4821L27.7618 35.176C26.3145 36.3183 24.4869 37 22.5 37C21.9882 37 21.4869 36.9548 21 36.8681V39C21 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.4397 11.0601 12.206 11.1665 12C11.3405 11.6631 11.6384 11.4006 12 11.2729V10H11C10.8017 10 10.6169 9.94228 10.4614 9.84272C10.1839 9.665 10 9.35398 10 9V5C10 4.96548 10.0017 4.93137 10.0052 4.89776C10.0564 4.3935 10.4822 4 11 4H21C21.5523 4 22 4.44772 22 5V9C22 9.35398 21.8161 9.665 21.5386 9.84272C21.3831 9.94228 21.1983 10 21 10H20V11.2729C20.3616 11.4006 20.6595 11.6631 20.8335 12C20.9399 12.206 21 12.4397 21 12.6875V20.1319ZM14 10H18V11.2729C18 11.9962 18.3892 12.6526 19 13.005V18H13V13.005C13.6108 12.6526 14 11.9962 14 11.2729V10ZM13 20V39C13 39.3738 13.0674 39.7272 13.189 40.0519C13.6163 41.193 14.7164 42 16 42C17.2836 42 18.3837 41.193 18.811 40.0519C18.9326 39.7272 19 39.3738 19 39V36.2483C16.0515 34.9143 14 31.9467 14 28.5C14 25.0533 16.0515 22.0857 19 20.7517V20H13ZM12 8H20V6H12V8ZM21 22.1739C20.2796 22.3441 19.6055 22.6341 19 23.0218C17.1958 24.1769 16 26.1988 16 28.5C16 30.8012 17.1958 32.8231 19 33.9782C19.6055 34.3659 20.2796 34.6559 21 34.8261C21.4815 34.9398 21.9837 35 22.5 35C23.9341 35 25.2597 34.5356 26.3347 33.7489C26.8756 33.3531 27.3531 32.8756 27.7489 32.3347C28.5356 31.2597 29 29.9341 29 28.5C29 25.0784 26.3562 22.2743 23 22.0189V33.5H21V22.1739Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );