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 d="M23.5 26.5L25 21.5L26.5 26.5L25 28.5L23.5 26.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M39.5076 18.8528C40.9495 18.4201 42 17.0827 42 15.5V9.5C42 7.567 40.433 6 38.5 6C36.567 6 35 7.567 35 9.5V15.5C35 17.0882 36.0578 18.4293 37.5073 18.8572C37.5156 19.982 37.53 21.0565 37.5437 22.0829L37.5437 22.084C37.5925 25.735 37.6332 28.7779 37.367 31.3076C36.9902 34.8886 36.027 37.0735 33.8843 38.3364C31.0049 40.0334 26.6466 40.621 22.9785 40.1592C21.1519 39.9292 19.5904 39.4496 18.5169 38.7934C18.0832 38.5283 17.752 38.2509 17.5114 37.9649C19.3353 37.8622 21.1162 37.5323 22.5645 36.9429C24.3416 36.2197 25.9525 34.9442 25.999 32.9293C29.3918 32.4445 32 29.5268 32 26C32 22.4735 29.3923 19.5561 26 19.0709V13.1221H25.9971C25.999 13.0815 26 13.0408 26 13C26 10.2386 21.5228 8 16 8C10.4772 8 6 10.2386 6 13C6 13.0408 6.00098 13.0815 6.00292 13.1221H6V32.8396C6 34.8246 7.66523 36.0935 9.42952 36.8249C11.0703 37.5052 13.1448 37.8844 15.2301 37.9774C15.6179 39.0406 16.4595 39.8798 17.4738 40.4998C18.8728 41.3549 20.7381 41.8929 22.7287 42.1435C26.6951 42.6429 31.5327 42.0438 34.8998 40.0594C37.865 38.3118 38.9558 35.3206 39.356 31.5168C39.6352 28.8635 39.5922 25.6347 39.5426 21.9138C39.5294 20.9275 39.5158 19.9067 39.5076 18.8528ZM38.5 8C39.3284 8 40 8.67157 40 9.5V15.5C40 16.3284 39.3284 17 38.5 17C37.6716 17 37 16.3284 37 15.5V9.5C37 8.67157 37.6716 8 38.5 8ZM24 13C24 13.2151 23.7737 13.9482 22.1766 14.7467C20.6992 15.4854 18.5183 16 16 16C13.4817 16 11.3008 15.4854 9.82336 14.7467C8.22632 13.9482 8 13.2151 8 13C8 12.7849 8.22632 12.0518 9.82336 11.2533C11.3008 10.5146 13.4817 10 16 10C18.5183 10 20.6992 10.5146 22.1766 11.2533C23.7737 12.0518 24 12.7849 24 13ZM24 16.0005C22.1755 17.2147 19.2712 18 16 18C15.6936 18 15.3903 17.9931 15.0909 17.9796V35.968C15.3957 35.9849 15.703 35.9953 16.0114 35.9988C18.179 36.0235 20.2859 35.711 21.8105 35.0905C23.3243 34.4744 23.9533 33.707 23.9975 32.9287C20.6064 32.4424 18 29.5256 18 26C18 22.4735 20.6077 19.5561 24 19.0709V16.0005ZM30 26C30 28.7614 27.7614 31 25 31C22.2386 31 20 28.7614 20 26C20 23.2386 22.2386 21 25 21C27.7614 21 30 23.2386 30 26Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );