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="M10 6.04785C10 6.04785 10.4847 6.89804 11.1222 8.18563C11.9991 9.9566 13.1652 12.555 13.7574 14.907C13.8552 15.2956 13.9374 15.6775 14 16.0479V31.0479H16V25.7004C15.3609 24.5088 15 23.0924 15 21.4764C15 17.8907 18.1754 15.2873 20.8358 13.1061C21.4829 12.5755 22.0996 12.0699 22.6327 11.5813C22.7602 11.4644 22.8828 11.3486 23 11.2336V8.04785H25V11.2336C25.1172 11.3486 25.2398 11.4644 25.3673 11.5813C25.9004 12.0699 26.5171 12.5755 27.1642 13.1061C29.8246 15.2873 33 17.8907 33 21.4764C33 23.0924 32.6391 24.5088 32 25.7004V31.0479H34V16.0479C34.0538 15.6842 34.1314 15.3032 34.2279 14.911C34.7873 12.6376 35.9834 9.99048 36.8796 8.18513C37.5152 6.9048 38 6.04785 38 6.04785C38 6.04785 38.4846 6.89804 39.1222 8.18563C39.9991 9.9566 41.1652 12.555 41.7574 14.907C41.8552 15.2956 41.9374 15.6775 42 16.0479V42.0479H6V16.0479C6.05381 15.6842 6.13138 15.3032 6.22788 14.911C6.78734 12.6376 7.98339 9.99048 8.87961 8.18513C9.5152 6.9048 10 6.04785 10 6.04785ZM28 40.0479V39.52C28 38.7624 27.572 38.0699 26.8944 37.7311L24 36.2839L21.1056 37.7311C20.428 38.0699 20 38.7624 20 39.52V40.0479H28ZM30 40.0479H34V33.0479H14V40.0479H18V39.52C18 38.0049 18.856 36.6198 20.2111 35.9423L24 34.0479L27.7889 35.9423C29.144 36.6198 30 38.0049 30 39.52V40.0479ZM36 16.516C36.8079 16.3205 37.4039 16.2228 38 16.2228C38.5961 16.2228 39.1921 16.3205 40 16.516V40.0479H36V16.516ZM8 16.516V40.0479H12L12 16.516C11.1921 16.3205 10.5961 16.2228 10 16.2228C9.40393 16.2228 8.80786 16.3205 8 16.516ZM8.4561 14.3735C8.85208 13.1141 9.41818 11.7408 9.99916 10.4783C10.562 11.7099 11.1211 13.0749 11.5271 14.3705C11.0002 14.2762 10.5022 14.2228 10 14.2228C9.49247 14.2228 8.98926 14.2773 8.4561 14.3735ZM17.9309 25.0479C17.3495 24.1017 17 22.9163 17 21.4764C17 20.3147 17.5051 19.2039 18.4659 18.0338C19.4453 16.8411 20.744 15.7677 22.1038 14.6528L22.1315 14.6301C22.764 14.1115 23.4214 13.5726 24 13.041C24.5787 13.5726 25.236 14.1115 25.8685 14.6301L25.8962 14.6528C27.256 15.7677 28.5547 16.8411 29.5341 18.0338C30.4949 19.2039 31 20.3147 31 21.4764C31 22.9163 30.6505 24.1017 30.0691 25.0479H17.9309ZM18 27.0479V31.0479H19V30.0479C19 29.4956 19.4477 29.0479 20 29.0479C20.5523 29.0479 21 29.4956 21 30.0479V31.0479H23V30.0479C23 29.4956 23.4477 29.0479 24 29.0479C24.5523 29.0479 25 29.4956 25 30.0479V31.0479H27V30.0479C27 29.4956 27.4477 29.0479 28 29.0479C28.5523 29.0479 29 29.4956 29 30.0479V31.0479H30V27.0479H18ZM37.9992 10.4783C37.4182 11.7408 36.8521 13.1141 36.4561 14.3735C36.9893 14.2773 37.4925 14.2228 38 14.2228C38.5022 14.2228 39.0002 14.2762 39.5271 14.3705C39.1211 13.0749 38.562 11.7099 37.9992 10.4783Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);