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="M34.5461 11.8407L25.7123 7.40399C24.6398 6.86534 23.3602 6.86534 22.2877 7.40399L13.4539 11.8407C13.3537 11.8911 13.2478 11.9302 13.1431 11.9715C12.4567 12.2424 12 12.8866 12 13.6095V13.6297V20.8575C12 22.0967 12.1983 23.1273 12.5553 24C13.9547 27.4199 17.7927 28.4127 21.6923 30.0154V27.1632V26.4726C19.2634 25.5509 17.5385 23.2168 17.5385 20.483C17.5385 16.9426 20.4314 14.0726 24 14.0726C27.5686 14.0726 30.4615 16.9426 30.4615 20.483C30.4615 23.2168 28.7367 25.5509 26.3077 26.4726V27.1632V30.0154C30.4905 28.4526 34.2131 27.5748 35.5113 24C35.8276 23.1289 36 22.0977 36 20.8575V13.6297V13.6095C36 12.8866 35.5433 12.2424 34.8569 11.9715C34.7522 11.9302 34.6463 11.8911 34.5461 11.8407Z" fill="black"/>
<path d="M36 13.6095V13.6297V20.8575C36 22.0977 35.8276 23.1289 35.5113 24M36 13.6095C36 12.8866 35.5433 12.2424 34.8569 11.9715C34.7522 11.9302 34.6463 11.8911 34.5461 11.8407L25.7123 7.40399C24.6398 6.86534 23.3602 6.86534 22.2877 7.40399L13.4539 11.8407C13.3537 11.8911 13.2478 11.9302 13.1431 11.9715C12.4567 12.2424 12 12.8866 12 13.6095V13.6297M36 13.6095H38C39.6569 13.6095 41 14.9526 41 16.6095V21C41 22.6569 39.6569 24 38 24H35.5113M12 13.6297V20.8575C12 22.0967 12.1983 23.1273 12.5553 24M12 13.6297L10.0121 13.6217C8.35056 13.615 7 14.9601 7 16.6217V21C7 22.6569 8.34315 24 10 24H12.5553M21.6923 42V31.344V30.0154M26.3077 42V31.344V30.0154M21.6923 30.0154V27.1632M21.6923 30.0154C17.7927 28.4127 13.9547 27.4199 12.5553 24M26.3077 30.0154V27.1632M26.3077 30.0154C30.4905 28.4526 34.2131 27.5748 35.5113 24M21.6923 22.9297V20.6213C21.6923 19.3984 22.7255 18.407 24 18.407C25.2745 18.407 26.3077 19.3984 26.3077 20.6213V22.9297M21.6923 22.9297V27.1632M21.6923 22.9297V26.4726M26.3077 22.9297V27.1632M26.3077 22.9297V26.4726M21.6923 27.1632V26.4726M26.3077 27.1632V26.4726M26.3077 26.4726C28.7367 25.5509 30.4615 23.2168 30.4615 20.483C30.4615 16.9426 27.5686 14.0726 24 14.0726C20.4314 14.0726 17.5385 16.9426 17.5385 20.483C17.5385 23.2168 19.2634 25.5509 21.6923 26.4726" stroke="black" stroke-width="2"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);