build method
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:
- the fields of the widget, which themselves must not change over time, and
- any ambient state obtained from the
context
using BuildContext.dependOnInheritedWidgetOfExactType.
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="M21 6C20.4477 6 20 6.44772 20 7C20 7.55228 20.4477 8 21 8H22V11C22 11.0137 22.0003 11.0274 22.0008 11.041C19.4378 11.2523 17.1032 12.269 15.2505 13.8375C15.2412 13.8274 15.2316 13.8174 15.2218 13.8076L13.1005 11.6863L13.8076 10.9792C14.1981 10.5886 14.1981 9.95547 13.8076 9.56495C13.4171 9.17442 12.7839 9.17442 12.3934 9.56495L9.56497 12.3934C9.17445 12.7839 9.17445 13.4171 9.56497 13.8076C9.9555 14.1981 10.5887 14.1981 10.9792 13.8076L11.6863 13.1005L13.8076 15.2218C13.8174 15.2316 13.8274 15.2412 13.8375 15.2505C12.269 17.1031 11.2523 19.4378 11.041 22.0008C11.0274 22.0003 11.0137 22 11 22H8V21C8 20.4477 7.55228 20 7 20C6.44772 20 6 20.4477 6 21V25C6 25.5523 6.44772 26 7 26C7.55228 26 8 25.5523 8 25V24H11C11.0137 24 11.0274 23.9997 11.041 23.9992C11.2522 26.5625 12.269 28.897 13.8375 30.7495C13.8274 30.7589 13.8174 30.7684 13.8076 30.7783L11.6863 32.8996L10.9791 32.1925C10.5886 31.802 9.95545 31.802 9.56493 32.1925C9.17441 32.583 9.17441 33.2162 9.56493 33.6067L12.3934 36.4351C12.7839 36.8257 13.417 36.8257 13.8076 36.4351C14.1981 36.0446 14.1981 35.4114 13.8076 35.0209L13.1005 34.3138L15.2218 32.1925C15.2317 32.1826 15.2413 32.1726 15.2506 32.1624C16.8143 33.4861 18.7214 34.4168 20.8193 34.8022C21.3625 34.9019 21.8838 34.5425 21.9835 33.9993C22.0833 33.4561 21.7239 32.9349 21.1807 32.8351C16.5265 31.9802 13 27.9009 13 23C13 17.4772 17.4772 13 23 13C27.9009 13 31.9802 16.5265 32.8351 21.1807C32.9349 21.7239 33.4561 22.0833 33.9993 21.9835C34.5425 21.8838 34.9019 21.3625 34.8022 20.8193C34.4168 18.7214 33.4861 16.8143 32.1624 15.2506C32.1643 15.2488 32.1662 15.2471 32.1681 15.2453C32.1763 15.2376 32.1844 15.2298 32.1924 15.2218L34.3137 13.1005L35.0208 13.8076C35.4113 14.1981 36.0445 14.1981 36.435 13.8076C36.8256 13.4171 36.8256 12.7839 36.435 12.3934L33.6066 9.56495C33.2161 9.17442 32.5829 9.17442 32.1924 9.56495C31.8019 9.95547 31.8019 10.5886 32.1924 10.9792L32.8995 11.6863L30.7782 13.8076C30.7684 13.8174 30.7588 13.8274 30.7495 13.8375C28.897 12.269 26.5624 11.2522 23.9992 11.041C23.9997 11.0274 24 11.0137 24 11V8H25C25.5523 8 26 7.55228 26 7C26 6.44772 25.5523 6 25 6H21Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M16 20.5C16 18.567 17.567 17 19.5 17C21.433 17 23 18.567 23 20.5C23 22.433 21.433 24 19.5 24C17.567 24 16 22.433 16 20.5ZM19.5 19C18.6716 19 18 19.6716 18 20.5C18 21.3284 18.6716 22 19.5 22C20.3284 22 21 21.3284 21 20.5C21 19.6716 20.3284 19 19.5 19Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M31.5 23C26.8056 23 23 26.8056 23 31.5C23 36.1944 26.8056 40 31.5 40C33.4869 40 35.3145 39.3183 36.7618 38.176L41.2929 42.7071C41.6834 43.0976 42.3166 43.0976 42.7071 42.7071C43.0976 42.3166 43.0976 41.6834 42.7071 41.2929L38.176 36.7618C39.3183 35.3145 40 33.4869 40 31.5C40 26.8056 36.1944 23 31.5 23ZM25 31.5C25 27.9101 27.9101 25 31.5 25C35.0899 25 38 27.9101 38 31.5C38 35.0899 35.0899 38 31.5 38C27.9101 38 25 35.0899 25 31.5Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);