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="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2 2V20C2 21.1046 2.89543 22 4 22H22V20H4V8.15637C4.91911 8.29004 6.08455 8.60683 7.01056 9.22734C7.65911 9.66192 8.20585 10.3263 8.67078 11.0359C8.89984 11.3855 9.09965 11.7311 9.27913 12.0493C9.31143 12.1066 9.34395 12.1646 9.37643 12.2225C9.51398 12.4679 9.65112 12.7125 9.76989 12.8979C10.7906 14.4918 12.7233 16 15.1792 16H18.5148L17.3816 17.3599L18.918 18.6402L21.9515 15L18.918 11.3599L17.3816 12.6402L18.5147 14H15.1792C13.5753 14 12.2095 12.9989 11.4541 11.8193C11.37 11.6881 11.2717 11.5128 11.1381 11.2748C11.1018 11.2102 11.063 11.141 11.0211 11.0668C10.8355 10.7375 10.6097 10.3459 10.3437 9.93978C9.81835 9.13802 9.09643 8.21755 8.12389 7.56586C6.79132 6.67292 5.18597 6.27915 4 6.1397V2H2Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.2079 7.59988H14.2C14.2 7.18532 14.1993 7.01622 14.188 6.91632C14.1818 6.86194 14.1805 6.85738 14.1265 6.75129L14.1237 6.7459C13.9161 6.32217 13.8 5.85042 13.8 5.35378C13.8 3.47199 15.4425 2 17.4 2C19.3574 2 20.9999 3.47199 20.9999 5.35378C20.9999 5.85081 20.8837 6.32288 20.6757 6.74686L20.6731 6.7522C20.6194 6.8577 20.6181 6.86203 20.612 6.9163C20.6007 7.01617 20.5999 7.18535 20.5999 7.59988H20.5962V7.87804L20.6007 7.87888V8.1302C20.6007 8.38415 20.3519 8.55974 20.1189 8.66069C20.0023 8.71118 19.9006 8.79567 19.8249 8.90497C19.7492 9.01427 19.7023 9.1442 19.6893 9.28063C19.6496 9.6981 19.5738 10.0008 19.1544 10L18.7713 9.9993V9.99662H16.0294V9.9993L15.6457 10C15.2262 10.0008 15.1512 9.69826 15.1115 9.28063C15.0985 9.1442 15.0516 9.01427 14.9759 8.90497C14.9001 8.79567 14.7984 8.71118 14.6819 8.66069C14.4489 8.55974 14.2 8.38415 14.2 8.1302V7.87888L14.2079 7.87744V7.59988ZM16.15 5.5C15.7358 5.5 15.4 5.83579 15.4 6.25C15.4 6.66421 15.7358 7 16.15 7C16.5643 7 16.9 6.66421 16.9 6.25C16.9 5.83579 16.5643 5.5 16.15 5.5ZM18.65 5.5C18.2358 5.5 17.9 5.83579 17.9 6.25C17.9 6.66421 18.2358 7 18.65 7C19.0643 7 19.4 6.66421 19.4 6.25C19.4 5.83579 19.0643 5.5 18.65 5.5Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);