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 fill-rule="evenodd" clip-rule="evenodd" d="M33.9645 42.9501C32.7958 43.6182 31.4425 44 29.9999 44C25.5816 44 21.9999 40.4183 21.9999 36C21.9999 33.4504 23.1926 31.1793 25.0506 29.7144C25.0172 29.4811 24.9999 29.2425 24.9999 29V9C24.9999 6.23858 27.2385 4 29.9999 4C32.7613 4 34.9999 6.23858 34.9999 9V29C34.9999 29.2425 34.9827 29.4811 34.9493 29.7144C36.8072 31.1793 37.9999 33.4504 37.9999 36C37.9999 38.8725 36.486 41.3914 34.2126 42.8023L34.0146 43.0003L33.9645 42.9501ZM26.2889 31.2849L26.2947 31.2803L34.7196 39.7051C34.5484 39.9229 34.3624 40.1285 34.1633 40.3205L25.6793 31.8366C25.8695 31.6394 26.0732 31.455 26.2889 31.2849ZM24.5343 33.52C24.4091 33.7957 24.3041 34.0825 24.2213 34.3785L31.6212 41.7784C31.9172 41.6955 32.204 41.5905 32.4796 41.4652L24.5343 33.52ZM24.0974 37.0831C24.5433 39.5285 26.4714 41.4567 28.9168 41.9025L24.0974 37.0831ZM35.7053 37.8624L27.0041 29.1614C27.0013 29.1081 26.9999 29.0543 26.9999 29V27.9856L35.9304 36.916C35.8807 37.2408 35.8049 37.557 35.7053 37.8624ZM35.5444 33.7016L26.9999 25.1572V23.9855L32.963 29.9486C33.0244 30.4687 33.2888 30.952 33.7109 31.2849C34.5132 31.9174 35.1486 32.7476 35.5444 33.7016ZM29.9999 6C28.3431 6 26.9999 7.34315 26.9999 9V21.0183C27.2379 21.0385 27.472 21.0738 27.6972 21.1154C28.188 21.206 28.7252 21.3454 29.2531 21.4824C29.27 21.4868 29.2868 21.4912 29.3036 21.4955C29.4212 21.5261 29.5384 21.5564 29.6543 21.586C30.7431 21.8635 31.8568 22.1071 32.9999 22.0852V20H30.9999C30.4476 20 29.9999 19.5523 29.9999 19C29.9999 18.4477 30.4476 18 30.9999 18H32.9999V16H30.9999C30.4476 16 29.9999 15.5523 29.9999 15C29.9999 14.4477 30.4476 14 30.9999 14H32.9999V12H30.9999C30.4476 12 29.9999 11.5523 29.9999 11C29.9999 10.4477 30.4476 10 30.9999 10H32.9999V9C32.9999 7.34315 31.6568 6 29.9999 6ZM32.9999 27.1571L29.4364 23.5935C29.8997 23.7086 30.3992 23.823 30.9273 23.9125L32.9999 25.9852V27.1571Z" fill="black"/>
<path d="M16.3301 12C16.3301 11.4477 15.8824 11 15.3301 11C14.7778 11 14.3301 11.4477 14.3301 12V15.268L11.5 13.6341C11.0217 13.3579 10.4101 13.5218 10.134 14.0001C9.85782 14.4784 10.0217 15.09 10.5 15.3661L13.3299 17L10.4999 18.6339C10.0216 18.91 9.85776 19.5216 10.1339 19.9999C10.41 20.4782 11.0216 20.6421 11.4999 20.3659L14.3301 18.7319V22C14.3301 22.5523 14.7778 23 15.3301 23C15.8824 23 16.3301 22.5523 16.3301 22V18.7321L19.1602 20.3661C19.6385 20.6423 20.2501 20.4784 20.5263 20.0001C20.8024 19.5218 20.6385 18.9102 20.1602 18.6341L17.3299 17L20.1602 15.3659C20.6385 15.0898 20.8023 14.4782 20.5262 13.9999C20.2501 13.5216 19.6385 13.3577 19.1602 13.6339L16.3301 15.2678V12Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);