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
contextusing 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="M13 5C13 4.44772 13.4477 4 14 4H24C24.5523 4 25 4.44772 25 5V9C25 9.55228 24.5523 10 24 10H23V11.2729C23.5826 11.4788 24 12.0344 24 12.6875V24.9993C23.2428 25.5681 22.5689 26.2418 22 26.999V24.9853L17.0153 20H16V21.1569L21.9327 27.0897C21.5261 27.6437 21.1753 28.2411 20.8883 28.8737L16 23.9854V26.1569L20.3208 30.4777C20.1126 31.279 20.0012 32.1193 20 32.9854L16 28.9854V31.1569L20.3054 35.4624C20.8401 37.5739 22.0465 39.4178 23.684 40.7533C22.9737 42.6499 21.1445 44 19 44C16.2386 44 14 41.7614 14 39V12.6875C14 12.0344 14.4174 11.4788 15 11.2729V10H14C13.4477 10 13 9.55228 13 9V5ZM22 13.1021C21.4174 12.8962 21 12.3406 21 11.6875V10H17V11.6875C17 12.3406 16.5826 12.8962 16 13.1021V18H22V13.1021ZM22 22.1567L19.8436 20H21.0147L22 20.9853V22.1567ZM21.0414 41.1983L16 36.1568V33.9854L21.8748 39.8602C21.7198 40.3792 21.4281 40.8391 21.0414 41.1983ZM19.0146 42L16 38.9853V39C16 40.6569 17.3431 42 19 42L19.0146 42ZM15 8V6H23V8H15Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M31 27C31.5523 27 32 26.5523 32 26C32 25.4477 31.5523 25 31 25H29C28.4477 25 28 25.4477 28 26C28 26.5523 28.4477 27 29 27V28.1C28.3616 28.2296 27.7674 28.4808 27.2426 28.8284L26.4143 28.0001C26.8048 27.6096 26.8048 26.9764 26.4143 26.5859C26.0237 26.1953 25.3906 26.1953 25 26.5859L24.3024 27.2835L24.2929 27.2929L24.2835 27.3024L23.5858 28.0001C23.1953 28.3906 23.1953 29.0238 23.5858 29.4143C23.9764 29.8048 24.6095 29.8048 25 29.4143L25.8284 30.2426C25.4808 30.7674 25.2296 31.3616 25.1 32H24C24 31.4477 23.5523 31 23 31C22.4477 31 22 31.4477 22 32V34C22 34.5523 22.4477 35 23 35C23.5523 35 24 34.5523 24 34H25.1C25.2296 34.6384 25.4808 35.2326 25.8284 35.7574L25 36.5859C24.6094 36.1953 23.9763 36.1953 23.5857 36.5859C23.1952 36.9764 23.1952 37.6096 23.5857 38.0001L25 39.4143C25.3905 39.8048 26.0236 39.8048 26.4142 39.4143C26.8047 39.0238 26.8047 38.3906 26.4142 38.0001L27.2426 37.1716C27.7674 37.5192 28.3616 37.7704 29 37.9V39C28.4477 39 28 39.4477 28 40C28 40.5523 28.4477 41 29 41H31C31.5523 41 32 40.5523 32 40C32 39.4477 31.5523 39 31 39V37.9C31.6384 37.7704 32.2326 37.5192 32.7574 37.1716L33.5858 38.0001C33.1953 38.3906 33.1953 39.0238 33.5858 39.4143C33.9764 39.8048 34.6095 39.8048 35 39.4143L36.4143 38.0001C36.8048 37.6096 36.8048 36.9764 36.4143 36.5859C36.0237 36.1953 35.3906 36.1953 35 36.5859L34.1716 35.7574C34.5192 35.2326 34.7704 34.6384 34.9 34H36C36 34.5523 36.4477 35 37 35C37.5523 35 38 34.5523 38 34V32C38 31.4477 37.5523 31 37 31C36.4477 31 36 31.4477 36 32H34.9C34.7704 31.3616 34.5192 30.7674 34.1716 30.2426L35 29.4141C35.3906 29.8047 36.0237 29.8047 36.4143 29.4141C36.8048 29.0236 36.8048 28.3904 36.4143 27.9999L35 26.5857C34.6095 26.1952 33.9764 26.1952 33.5858 26.5857C33.1953 26.9762 33.1953 27.6094 33.5858 27.9999L32.7574 28.8284C32.2326 28.4808 31.6384 28.2296 31 28.1V27ZM30 30C28.3431 30 27 31.3431 27 33C27 34.6569 28.3431 36 30 36C31.6569 36 33 34.6569 33 33C33 31.3431 31.6569 30 30 30Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);