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.0178 17.3352C18.1429 17.9112 15 19.2026 15 21V24H33V21C33 19.2026 29.8571 17.9112 26.9822 17.3352C25.8862 17.1156 24.8291 17 24 17C23.1709 17 22.1138 17.1156 21.0178 17.3352ZM31 22V21.1141C30.9653 21.0696 30.8947 20.9926 30.7604 20.8842C30.3888 20.5844 29.7704 20.2531 28.9358 19.946C27.268 19.3324 25.2514 19 24 19C22.7486 19 20.732 19.3324 19.0642 19.946C18.2296 20.2531 17.6112 20.5844 17.2396 20.8842C17.1053 20.9926 17.0347 21.0696 17 21.1141V22H31ZM16.9703 21.1594C16.9703 21.1594 16.9715 21.1554 16.9764 21.1474C16.9731 21.1554 16.9703 21.1594 16.9703 21.1594ZM31.0297 21.1594C31.0297 21.1594 31.0269 21.1554 31.0236 21.1474C31.0285 21.1554 31.0297 21.1594 31.0297 21.1594Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.3504 15.2416C22.1185 15.7222 23.0266 16 24 16C24.9734 16 25.8815 15.7222 26.6496 15.2416C28.0615 14.3581 29 12.7892 29 11C29 8.2375 26.7625 6 24 6C21.2375 6 19 8.2375 19 11C19 12.7892 19.9385 14.3581 21.3504 15.2416ZM24 14C25.6579 14 27 12.6579 27 11C27 9.34207 25.6579 8 24 8C22.3421 8 21 9.34207 21 11C21 12.6579 22.3421 14 24 14Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M25 31.7647V34.126C26.7252 34.5701 28 36.1362 28 38C28 40.2091 26.2091 42 24 42C21.7909 42 20 40.2091 20 38C20 36.1362 21.2748 34.5701 23 34.126V31.7647H11V34.126C12.7252 34.5701 14 36.1362 14 38C14 40.2091 12.2091 42 10 42C7.79086 42 6 40.2091 6 38C6 36.1362 7.27477 34.5701 9 34.126V31.7647C9 30.6601 9.89543 29.7647 11 29.7647L23 29.7647V26H25V29.7647L37 29.7647C38.1046 29.7647 39 30.6601 39 31.7647V34.126C40.7252 34.5701 42 36.1362 42 38C42 40.2091 40.2091 42 38 42C35.7909 42 34 40.2091 34 38C34 36.1362 35.2748 34.5701 37 34.126V31.7647H25ZM38 36C36.8954 36 36 36.8954 36 38C36 39.1046 36.8954 40 38 40C39.1046 40 40 39.1046 40 38C40 36.8954 39.1046 36 38 36ZM10 36C8.89543 36 8 36.8954 8 38C8 39.1046 8.89543 40 10 40C11.1046 40 12 39.1046 12 38C12 36.8954 11.1046 36 10 36ZM24 40C25.1046 40 26 39.1046 26 38C26 36.8954 25.1046 36 24 36C22.8954 36 22 36.8954 22 38C22 39.1046 22.8954 40 24 40Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );