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="M5.99715 12H35.9543V13.0956C36.6506 13.1985 37.3198 13.3824 37.9515 13.6371V10H4V34H19.9772V36H15.9829C15.4314 36 14.9843 36.4477 14.9843 37C14.9843 37.5523 15.4314 38 15.9829 38H25.9686C26.5201 38 26.9672 37.5523 26.9672 37C26.9672 36.4477 26.5201 36 25.9686 36H21.9743V34H37.9515V29.358C37.3196 29.6128 36.6504 29.7968 35.9543 29.8998V32H5.99715V21.3749H12.32L14.3574 18.0619L17.8165 25.0619L21.1599 19.6249H26.5854C26.7069 18.9226 26.9198 18.2517 27.2115 17.6249H20.0443L18.0069 20.938L14.5479 13.938L11.2045 19.3749H5.99715V12Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M34.8061 28C36.366 28 37.7973 27.449 38.9166 26.5307L42.5878 30.2071L44 28.7928L40.2514 25.0389C40.9127 24.0206 41.2968 22.8052 41.2968 21.5C41.2968 17.9101 38.3908 15 34.8061 15C31.2213 15 28.3154 17.9101 28.3154 21.5C28.3154 25.0899 31.2213 28 34.8061 28ZM34.8061 26C37.2878 26 39.2997 23.9853 39.2997 21.5C39.2997 19.0147 37.2878 17 34.8061 17C32.3243 17 30.3125 19.0147 30.3125 21.5C30.3125 23.9853 32.3243 26 34.8061 26Z" fill="black"/>
<path d="M7.99429 26H13.9857V24H7.99429V26Z" fill="black"/>
<path d="M7.99429 30V28H19.9772V30H7.99429Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);