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="M13 18C13 13.0294 17.0294 9 22 9H26C29.9239 9 33.2532 11.5093 34.4871 15.0003C35.0392 16.5624 34.2205 18.2764 32.6583 18.8285C31.0962 19.3807 29.3822 18.5619 28.8301 16.9997C28.4172 15.8315 27.3026 15 26 15H22C20.3431 15 19 16.3431 19 18C19 19.6569 20.3431 21 22 21H26C30.9706 21 35 25.0294 35 30C35 34.9706 30.9706 39 26 39H22C18.0761 39 14.7468 36.4907 13.5129 32.9997C12.9608 31.4376 13.7795 29.7236 15.3417 29.1715C16.9038 28.6193 18.6178 29.4381 19.1699 31.0003C19.5828 32.1685 20.6974 33 22 33H26C27.6569 33 29 31.6569 29 30C29 28.3431 27.6569 27 26 27H22C17.0294 27 13 22.9706 13 18ZM22 11C18.134 11 15 14.134 15 18C15 21.866 18.134 25 22 25H26C28.7614 25 31 27.2386 31 30C31 32.7614 28.7614 35 26 35H22C19.8256 35 17.9715 33.6111 17.2843 31.6668C17.1002 31.146 16.5289 30.8731 16.0082 31.0572C15.4874 31.2412 15.2145 31.8125 15.3986 32.3332C16.3592 35.0512 18.9511 37 22 37H26C29.866 37 33 33.866 33 30C33 26.134 29.866 23 26 23H22C19.2386 23 17 20.7614 17 18C17 15.2386 19.2386 13 22 13H26C28.1744 13 30.0285 14.3889 30.7157 16.3332C30.8998 16.854 31.4711 17.1269 31.9918 16.9428C32.5126 16.7588 32.7855 16.1875 32.6014 15.6668C31.6408 12.9488 29.0489 11 26 11H22Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );