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 22H22V20H4V16.0193C4.73511 16.0339 5.63921 16.0055 6.7559 15.7099C7.52669 15.5058 8.23588 15.0817 8.79252 14.7488C8.88625 14.6927 8.97566 14.6393 9.06031 14.5899C9.72187 14.2038 10.1818 14 10.6344 14C11.2711 14 11.7173 14.2294 12.323 14.6086C12.3785 14.6433 12.436 14.6799 12.4955 14.7177C13.0646 15.0797 13.8205 15.5603 14.8356 15.7296C16.1933 15.9559 16.809 15.9879 18.5211 15.9925L17.3816 17.3599L18.918 18.6402L21.9515 15L18.918 11.3599L17.3816 12.6402L18.5084 13.9924C16.853 13.9876 16.3645 13.9568 15.1644 13.7568C14.5668 13.6571 14.1415 13.3896 13.538 13.0099L13.3844 12.9135C12.7157 12.4948 11.8632 12 10.6343 12C9.59275 12 8.71807 12.4739 8.05226 12.8625C7.93647 12.93 7.82646 12.9952 7.72111 13.0576L7.72016 13.0581C7.15268 13.3942 6.71998 13.6505 6.2441 13.7765C5.32617 14.0194 4.67014 14.0328 4 14.0161V2H2Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.40781 7.59988H6.39999C6.39999 7.18532 6.39927 7.01622 6.38792 6.91632C6.38174 6.86194 6.38042 6.85738 6.32643 6.75129L6.32368 6.7459C6.11604 6.32217 6 5.85042 6 5.35378C6 3.47199 7.6425 2 9.59994 2C11.5574 2 13.1999 3.47199 13.1999 5.35378C13.1999 5.85081 13.0836 6.32288 12.8757 6.74686L12.8731 6.7522C12.8194 6.8577 12.8181 6.86203 12.8119 6.9163C12.8006 7.01617 12.7999 7.18535 12.7999 7.59988H12.7961V7.87804L12.8007 7.87888V8.1302C12.8007 8.38415 12.5519 8.55974 12.3188 8.66069C12.2023 8.71118 12.1006 8.79567 12.0249 8.90497C11.9491 9.01427 11.9022 9.1442 11.8892 9.28063C11.8495 9.6981 11.7737 10.0008 11.3544 10L10.9713 9.9993V9.99662H8.2294V9.9993L7.8457 10C7.42618 10.0008 7.35116 9.69826 7.31144 9.28063C7.29847 9.1442 7.25156 9.01427 7.17582 8.90497C7.10007 8.79567 6.9984 8.71118 6.88184 8.66069C6.64881 8.55974 6.39999 8.38415 6.39999 8.1302V7.87888L6.40781 7.87744V7.59988ZM8.35 5.5C7.93579 5.5 7.6 5.83579 7.6 6.25C7.6 6.66421 7.93579 7 8.35 7C8.76421 7 9.1 6.66421 9.1 6.25C9.1 5.83579 8.76421 5.5 8.35 5.5ZM10.85 5.5C10.4358 5.5 10.1 5.83579 10.1 6.25C10.1 6.66421 10.4358 7 10.85 7C11.2642 7 11.6 6.66421 11.6 6.25C11.6 5.83579 11.2642 5.5 10.85 5.5Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);