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="M29 10C29 12.7614 26.7614 15 24 15C21.2386 15 19 12.7614 19 10C19 7.23858 21.2386 5 24 5C26.7614 5 29 7.23858 29 10Z" fill="black"/>
<path d="M31 43C31 43.5523 30.5523 44 30 44H12.8559C11.2786 44 10 42.7214 10 41.1441C10 40.1566 10.5102 39.2392 11.349 38.7182L16.6329 35.4363C17.5141 34.8889 18.05 33.9252 18.05 32.8878V32H20.424C21.4849 32 22.5023 31.5786 23.2524 30.8284L24 30.0809L24.7475 30.8284C25.4977 31.5786 26.5151 32 27.576 32H30V32.8915C30 33.9259 30.5329 34.8873 31.41 35.4355L36.6556 38.714C37.4919 39.2367 38 40.1534 38 41.1396C38 42.7194 36.7194 44 35.1396 44H32.8293C32.9398 43.6872 33 43.3506 33 43V42.7503C33 41.2472 31.8876 39.9761 30.3978 39.7767L17.1826 38.0088C16.6352 37.9356 16.1321 38.32 16.0588 38.8674C15.9856 39.4148 16.37 39.9179 16.9174 39.9912L30.1326 41.7591C30.6292 41.8255 31 42.2492 31 42.7503V43Z" fill="black"/>
<path d="M26.1617 29.4142L25 28.2525V24.51C25.1481 24.5956 25.2875 24.7017 25.4142 24.8284L27.2929 26.7071C27.4804 26.8946 27.7348 27 28 27H31C31.3466 27 31.6684 26.8205 31.8506 26.5257C32.0328 26.2309 32.0494 25.8628 31.8944 25.5528L30.8944 23.5528C30.6474 23.0588 30.0467 22.8586 29.5528 23.1056C29.0588 23.3526 28.8586 23.9532 29.1056 24.4472L29.3819 25H28.4142L26.8284 23.4142C25.2663 21.8521 22.7336 21.8521 21.1716 23.4142L19.5858 25H18.618L18.8944 24.4472C19.1414 23.9532 18.9412 23.3526 18.4472 23.1056C17.9532 22.8586 17.3525 23.0588 17.1056 23.5528L16.1056 25.5528C15.9506 25.8628 15.9671 26.2309 16.1493 26.5257C16.3315 26.8205 16.6534 27 17 27H20C20.2652 27 20.5195 26.8946 20.7071 26.7071L22.5858 24.8284C22.7125 24.7017 22.8519 24.5956 23 24.51V28.2525L21.8382 29.4142C21.4631 29.7893 20.9544 30 20.424 30H14.3855C12.9788 30 12.0116 28.5862 12.5215 27.2751L15.5256 19.5502C16.1235 18.0127 17.604 17 19.2536 17H28.7463C30.396 17 31.8764 18.0127 32.4743 19.5502L35.4785 27.2751C35.9883 28.5862 35.0212 30 33.6144 30H27.576C27.0455 30 26.5368 29.7893 26.1617 29.4142Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);