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="M34 16C34 21.525 29.525 26 24 26C18.475 26 14 21.525 14 16C14 10.475 18.475 6 24 6C29.525 6 34 10.475 34 16ZM24 24C28.4204 24 32 20.4204 32 16C32 11.5796 28.4204 8 24 8C19.5796 8 16 11.5796 16 16C16 20.4204 19.5796 24 24 24Z" fill="black"/>
<path d="M24 28C17.9925 28 6 31.0347 6 36V42H24V40H8V36C8 35.6291 8.22038 35.0211 9.22348 34.2119C10.2042 33.4207 11.6659 32.6669 13.4378 32.015C16.9801 30.7117 21.2468 30 24 30V28Z" fill="black"/>
<path d="M28 29H26V34H31V32H29.55L29.8 31.75C30.4 31.15 31.0542 30.7083 31.7625 30.425C32.4708 30.1417 33.2 30 33.95 30C35.2333 30 36.3958 30.3667 37.4375 31.1C38.4792 31.8333 39.2167 32.8 39.65 34H41.75C41.2833 32.2167 40.3292 30.7708 38.8875 29.6625C37.4458 28.5542 35.8 28 33.95 28C32.95 28 31.9583 28.175 30.975 28.525C29.9917 28.875 29.1167 29.4833 28.35 30.35L28 30.75V29Z" fill="black"/>
<path d="M28.35 36H26.25C26.7167 37.7833 27.6708 39.2292 29.1125 40.3375C30.5542 41.4458 32.2 42 34.05 42C35.05 42 36.0292 41.8125 36.9875 41.4375C37.9458 41.0625 38.8333 40.4667 39.65 39.65L40 39.25V41H42V36H37V38H38.45L38.2 38.25C37.6 38.85 36.9458 39.2917 36.2375 39.575C35.5292 39.8583 34.8 40 34.05 40C32.7667 40 31.6042 39.6333 30.5625 38.9C29.5208 38.1667 28.7833 37.2 28.35 36Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);