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="M13 38C13 35.7909 14.7909 34 17 34C19.2091 34 21 35.7909 21 38C21 40.2091 19.2091 42 17 42C14.7909 42 13 40.2091 13 38ZM11.5549 35.4765C11.1988 36.2436 11 37.0986 11 38C11 39.5367 11.5777 40.9385 12.5278 42H11.0131C9.34903 42 8 40.651 8 38.9869C8 37.7815 8.71832 36.6921 9.82621 36.2173L11.5549 35.4765ZM21.4722 42H22.9869C24.651 42 26 40.651 26 38.9869C26 37.7815 25.2817 36.6921 24.1738 36.2173L22.4451 35.4765C22.8012 36.2436 23 37.0986 23 38C23 39.5367 22.4223 40.9385 21.4722 42Z" fill="black"/>
<path d="M16 12C16 14.2091 14.2091 16 12 16C9.79086 16 8 14.2091 8 12C8 9.79086 9.79086 8 12 8C14.2091 8 16 9.79086 16 12Z" fill="black"/>
<path d="M19 23V31C19 32.1046 18.1046 33 17 33C15.8954 33 15 32.1046 15 31V19.2715C15 15.8419 19.0333 14.0026 21.6228 16.2513L31.3871 24.7309C33.0468 26.1722 34 28.2625 34 30.4607C34 30.8198 33.9745 31.1784 33.9237 31.5339L33 38H40C41.1046 38 42 38.8954 42 40C42 41.1046 41.1046 42 40 42H30C28.8954 42 28 41.1046 28 40V32.7963C28 31.6537 27.5114 30.5657 26.6575 29.8066L19 23Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);