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="M14.6995 17.6581C15.8671 16.0983 17.6512 15 20 15H28C30.3488 15 32.1329 16.0983 33.3005 17.6581C34.4483 19.1913 35 21.1597 35 23V28C35 29.6569 33.6569 31 32 31C31.6494 31 31.3128 30.9398 31 30.8293V41.1627C31 42.7297 29.7297 44 28.1627 44C26.708 44 25.4894 42.8999 25.3404 41.4537L24.3593 33H23.6407L22.6596 41.4537C22.5106 42.8999 21.292 44 19.8373 44C18.2703 44 17 42.7297 17 41.1627V30.8293C16.6872 30.9398 16.3506 31 16 31C14.3431 31 13 29.6569 13 28V23C13 21.1597 13.5517 19.1913 14.6995 17.6581ZM20 17H28C29.6512 17 30.8671 17.7448 31.6995 18.8567C32.5517 19.995 33 21.5265 33 23V28C33 28.5523 32.5523 29 32 29C31.4477 29 31 28.5523 31 28V21.5H29V41.1627C29 41.6251 28.6251 42 28.1627 42C27.7326 42 27.3724 41.674 27.3296 41.246L27.3288 41.2381L26.2433 31.8847C26.1848 31.3804 25.7577 31 25.25 31H22.75C22.2423 31 21.8152 31.3804 21.7567 31.8847L20.6712 41.2381L20.6704 41.246C20.6276 41.674 20.2674 42 19.8373 42C19.3749 42 19 41.6251 19 41.1627V26.5H17V28C17 28.5523 16.5523 29 16 29C15.4477 29 15 28.5523 15 28V23C15 21.5265 15.4483 19.995 16.3005 18.8567C17.1329 17.7448 18.3488 17 20 17Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M26.5 8.5C26.5 9.88071 25.3807 11 24 11C22.6193 11 21.5 9.88071 21.5 8.5C21.5 7.11929 22.6193 6 24 6C25.3807 6 26.5 7.11929 26.5 8.5ZM28.5 8.5C28.5 10.9853 26.4853 13 24 13C21.5147 13 19.5 10.9853 19.5 8.5C19.5 6.01472 21.5147 4 24 4C26.4853 4 28.5 6.01472 28.5 8.5ZM31.5 9C32.3284 9 33 8.2312 33 7.28283C33 5.7803 31.5 4 31.5 4C31.5 4 30 5.7803 30 7.28283C30 8.2312 30.6716 9 31.5 9Z" fill="black"/>
<path d="M38 14.9394C38 16.0774 37.1046 17 36 17C34.8954 17 34 16.0774 34 14.9394C34 13.1364 36 11 36 11C36 11 38 13.1364 38 14.9394Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M34.7788 12.6459C35.3404 11.7045 36 11 36 11C36 11 36.6596 11.7045 37.2212 12.6459C37.6375 13.3437 38 14.1718 38 14.9394C38 16.0774 37.1046 17 36 17C34.8954 17 34 16.0774 34 14.9394C34 14.1718 34.3625 13.3437 34.7788 12.6459Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );