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="M20 7C20 6.44772 20.4477 6 21 6H25C25.5523 6 26 6.44772 26 7C26 7.55228 25.5523 8 25 8H24V11C24 11.0137 23.9997 11.0274 23.9992 11.041C26.5622 11.2523 28.8968 12.269 30.7495 13.8375C30.7588 13.8274 30.7684 13.8174 30.7782 13.8076L32.8995 11.6863L32.1924 10.9792C31.8019 10.5886 31.8019 9.95547 32.1924 9.56495C32.5829 9.17442 33.2161 9.17442 33.6066 9.56495L36.435 12.3934C36.8256 12.7839 36.8256 13.4171 36.435 13.8076C36.0445 14.1981 35.4113 14.1981 35.0208 13.8076L34.3137 13.1005L32.1924 15.2218C32.1826 15.2316 32.1726 15.2412 32.1625 15.2505C33.823 17.2118 34.8651 19.7133 34.9878 22.454C34.0443 22.159 33.0407 22 32 22C26.4772 22 22 26.4772 22 32C22 33.0407 22.159 34.0443 22.454 34.9878C19.7133 34.8651 17.2118 33.823 15.2505 32.1625C15.2488 32.1644 15.247 32.1663 15.2453 32.1682C15.2376 32.1764 15.2298 32.1845 15.2218 32.1925L13.1005 34.3138L13.8076 35.0209C14.1981 35.4114 14.1981 36.0446 13.8076 36.4351C13.417 36.8257 12.7839 36.8257 12.3934 36.4351L9.56493 33.6067C9.17441 33.2162 9.17441 32.583 9.56493 32.1925C9.95545 31.802 10.5886 31.802 10.9791 32.1925L11.6863 32.8996L13.8076 30.7783C13.8174 30.7684 13.8274 30.7589 13.8375 30.7495C12.269 28.8969 11.2523 26.5622 11.041 23.9992C11.0274 23.9997 11.0137 24 11 24H8V25C8 25.5523 7.55228 26 7 26C6.44772 26 6 25.5523 6 25V21C6 20.4477 6.44772 20 7 20C7.55228 20 8 20.4477 8 21V22H11C11.0137 22 11.0274 22.0003 11.041 22.0008C11.2523 19.4378 12.269 17.1031 13.8375 15.2505C13.8356 15.2488 13.8337 15.247 13.8318 15.2452C13.8237 15.2376 13.8156 15.2298 13.8076 15.2218L11.6863 13.1005L10.9792 13.8076C10.5887 14.1981 9.9555 14.1981 9.56497 13.8076C9.17445 13.4171 9.17445 12.7839 9.56497 12.3934L12.3934 9.56494C12.7839 9.17442 13.4171 9.17442 13.8076 9.56494C14.1981 9.95547 14.1981 10.5886 13.8076 10.9792L13.1005 11.6863L15.2218 13.8076C15.2316 13.8174 15.2412 13.8274 15.2505 13.8375C17.1032 12.269 19.4378 11.2523 22.0008 11.041C22.0003 11.0274 22 11.0137 22 11V8H21C20.4477 8 20 7.55228 20 7ZM22 20C22 21.6569 20.6569 23 19 23C17.3431 23 16 21.6569 16 20C16 18.3431 17.3431 17 19 17C20.6569 17 22 18.3431 22 20Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 32C24 27.5817 27.5817 24 32 24C36.4183 24 40 27.5817 40 32C40 33.8487 39.3729 35.551 38.3199 36.9056L42.7071 41.2929C43.0976 41.6834 43.0976 42.3166 42.7071 42.7071C42.3166 43.0976 41.6834 43.0976 41.2929 42.7071L36.9056 38.3199C35.551 39.3729 33.8487 40 32 40C27.5817 40 24 36.4183 24 32ZM32 26C28.6863 26 26 28.6863 26 32C26 35.3137 28.6863 38 32 38C35.3137 38 38 35.3137 38 32C38 28.6863 35.3137 26 32 26Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );