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="M7.54777 3.75L5.94168 8.76905C4.32067 13.8347 3.78111 19.1842 4.35791 24.4715L6.50609 44.1632L8.4943 43.9463L6.34611 24.2546C5.79967 19.2456 6.31083 14.1776 7.84652 9.3786L9.45262 4.35955L7.54777 3.75Z" fill="black"/>
<path d="M40.4522 3.75L42.0583 8.76905C43.6793 13.8347 44.2189 19.1842 43.6421 24.4715L41.4939 44.1632L39.5057 43.9463L41.6539 24.2546C42.2003 19.2456 41.6892 14.1776 40.1535 9.3786L38.5474 4.35955L40.4522 3.75Z" fill="black"/>
<path d="M26 24.0548C26 25.1594 25.1046 26.0548 24 26.0548C22.8955 26.0548 22 25.1594 22 24.0548C22 22.9502 22.8955 22.0548 24 22.0548C25.1046 22.0548 26 22.9502 26 24.0548Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.5 44.0548V34.9534C22.9905 35.0203 23.4912 35.0548 24 35.0548C24.5088 35.0548 25.0095 35.0203 25.5 34.9534V44.0548H27.5V34.4863C31.8592 33.0243 35 28.9063 35 24.0548C35 17.9797 30.0751 13.0548 24 13.0548C17.9249 13.0548 13 17.9797 13 24.0548C13 28.9063 16.1408 33.0243 20.5 34.4863V44.0548H22.5ZM22.5 17.0548C21.9478 17.0548 21.5 17.5025 21.5 18.0548C21.5 18.6071 21.9478 19.0548 22.5 19.0548H23V20.1808C22.3602 20.3455 21.7823 20.6646 21.3084 21.0959L19.9536 20.3137L20.2036 19.8807C20.4797 19.4024 20.3159 18.7908 19.8376 18.5147C19.3593 18.2385 18.7477 18.4024 18.4715 18.8807L16.9715 21.4788C16.6954 21.9571 16.8593 22.5686 17.3376 22.8448C17.8159 23.1209 18.4275 22.9571 18.7036 22.4788L18.9536 22.0457L20.2104 22.7714C20.074 23.1742 20 23.6059 20 24.0548C20 24.3473 20.0314 24.6324 20.091 24.907L18.9535 25.5638L18.7035 25.1308C18.4273 24.6525 17.8157 24.4886 17.3374 24.7648C16.8592 25.0409 16.6953 25.6525 16.9714 26.1308L18.4714 28.7289C18.7476 29.2072 19.3592 29.371 19.8374 29.0949C20.3157 28.8188 20.4796 28.2072 20.2035 27.7289L19.9535 27.2959L20.9948 26.6947C21.5165 27.2881 22.2112 27.7257 23 27.9288V29.0548H22.5C21.9478 29.0548 21.5 29.5025 21.5 30.0548C21.5 30.6071 21.9478 31.0548 22.5 31.0548H25.5C26.0523 31.0548 26.5 30.6071 26.5 30.0548C26.5 29.5025 26.0523 29.0548 25.5 29.0548H25V27.9288C25.7889 27.7258 26.4835 27.2881 27.0052 26.6947L28.0465 27.2959L27.7965 27.7289C27.5204 28.2072 27.6842 28.8188 28.1625 29.095C28.6408 29.3711 29.2524 29.2072 29.5285 28.7289L31.0285 26.1309C31.3047 25.6526 31.1408 25.041 30.6625 24.7648C30.1842 24.4887 29.5726 24.6526 29.2965 25.1309L29.0465 25.5639L27.909 24.9072C27.9686 24.6325 28 24.3473 28 24.0548C28 23.6059 27.9261 23.1743 27.7897 22.7715L29.0466 22.0458L29.2966 22.4788C29.5728 22.9571 30.1843 23.121 30.6626 22.8448C31.1409 22.5687 31.3048 21.9571 31.0287 21.4788L29.5287 18.8807C29.2525 18.4024 28.6409 18.2386 28.1626 18.5147C27.6843 18.7909 27.5205 19.4024 27.7966 19.8807L28.0466 20.3138L26.6918 21.096C26.2179 20.6646 25.6399 20.3455 25 20.1808V19.0548H25.5C26.0523 19.0548 26.5 18.6071 26.5 18.0548C26.5 17.5025 26.0523 17.0548 25.5 17.0548H22.5Z" fill="black"/>
<path d="M25.1499 6.05481C25.1499 5.50252 24.7022 5.05481 24.1499 5.05481C23.5976 5.05481 23.1499 5.50252 23.1499 6.05481V7.05481C23.1499 7.60709 23.5976 8.05481 24.1499 8.05481C24.7022 8.05481 25.1499 7.60709 25.1499 7.05481V6.05481Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );