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 22H22V20H4V19H5.17877C6.14495 19 7.15879 18.9817 8.17714 18.8485C9.26237 18.7065 10.8525 18.4278 12.0312 17.8851C14.8102 16.6054 16.5215 15.1423 18.1176 12.3578C18.7637 11.2305 19.1288 10.1341 19.3195 9.0899L20.4773 10.367L21.959 9.02372L18.7764 5.51314L14.7495 8.01049L15.8036 9.71018L17.348 8.75234C17.1918 9.59488 16.8969 10.4656 16.3824 11.3632C15.0069 13.7629 13.6219 14.9507 11.1946 16.0684C10.3118 16.4749 8.98335 16.726 7.91776 16.8654C7.0352 16.9808 6.1297 17 5.17877 17H4V2H2Z" 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,
);