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="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13 4.5C13 5.88071 11.8807 7 10.5 7C9.11929 7 8 5.88071 8 4.5C8 3.11929 9.11929 2 10.5 2C11.8807 2 13 3.11929 13 4.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M16.1961 12.4806C15.6545 12.5889 15.1277 12.2377 15.0194 11.6962C14.8494 10.8463 14.39 10.4691 13.7887 10.2543C13.6949 10.2208 13.5985 10.1917 13.5 10.1665L13.5 20.9289C13.5 21.5205 13.0205 22 12.4289 22C11.8959 22 11.444 21.6081 11.3686 21.0804L10.6429 16H10.3571L9.63137 21.0804C9.55599 21.6081 9.10408 22 8.57107 22C7.97953 22 7.5 21.5205 7.5 20.9289V15C5.567 15 4 13.433 4 11.5C4 9.567 5.567 8 7.5 8H12V8.00235C12.7017 8.01275 13.6165 8.06908 14.4613 8.37081C15.6099 8.78103 16.6506 9.65385 16.9806 11.3039C17.0889 11.8455 16.7377 12.3723 16.1961 12.4806ZM7.5 10C6.67157 10 6 10.6716 6 11.5C6 12.3284 6.67157 13 7.5 13V10Z" fill="black"/>
<path d="M17 14.4C17 14.1767 17.0873 14.0354 17.2134 13.9337C17.3579 13.8171 17.5628 13.75 17.75 13.75C17.9372 13.75 18.1421 13.8171 18.2866 13.9337C18.4127 14.0354 18.5 14.1767 18.5 14.4V21C18.5 21.4142 18.8358 21.75 19.25 21.75C19.6642 21.75 20 21.4142 20 21V14.4C20 13.6899 19.6808 13.1313 19.2286 12.7663C18.7948 12.4163 18.2497 12.25 17.75 12.25C17.2503 12.25 16.7052 12.4163 16.2714 12.7663C15.8192 13.1313 15.5 13.6899 15.5 14.4C15.5 14.8142 15.8358 15.15 16.25 15.15C16.6642 15.15 17 14.8142 17 14.4Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );