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="M11 8C9.34315 8 8 9.34315 8 11C8 12.6569 9.34315 14 11 14C12.6569 14 14 12.6569 14 11C14 9.34315 12.6569 8 11 8ZM6 11C6 8.23858 8.23858 6 11 6C13.7614 6 16 8.23858 16 11C16 13.7614 13.7614 16 11 16C8.23858 16 6 13.7614 6 11ZM20.9671 16.0064C19.025 14.3198 16 15.6993 16 18.2715V31C16 31.5523 16.4477 32 17 32C17.5523 32 18 31.5523 18 31V22C18 21.6062 18.2311 21.2491 18.5903 21.0878C18.9496 20.9264 19.37 20.991 19.6644 21.2526L27.3218 28.0592C28.3893 29.0081 29 30.3681 29 31.7963V39C29 39.5523 29.4477 40 30 40H39C39.5523 40 40 39.5523 40 39C40 38.4477 39.5523 38 39 38H33C32.7101 38 32.4345 37.8742 32.2445 37.6552C32.0546 37.4362 31.9691 37.1456 32.01 36.8586L32.9338 30.3925C32.9779 30.0838 33 29.7725 33 29.4607C33 27.5521 32.1724 25.7373 30.7314 24.4859L20.9671 16.0064ZM14.2872 32.2826C14.103 31.8937 14 31.4589 14 31V18.2715C14 13.9845 19.0416 11.6854 22.2784 14.4963L32.0428 22.9758C33.9212 24.6071 35 26.9728 35 29.4607C35 29.8671 34.9712 30.273 34.9137 30.6753L34.153 36H39C40.6569 36 42 37.3431 42 39C42 40.6569 40.6569 42 39 42H30C28.3431 42 27 40.6569 27 39V31.7963C27 30.9394 26.6336 30.1233 25.9931 29.554L20 24.2268V31C20 31.4589 19.897 31.8937 19.7128 32.2826C19.9102 32.3519 20.1036 32.4338 20.2918 32.5279L23.739 34.2515C25.1247 34.9443 26 36.3606 26 37.9098C26 40.1688 24.1688 42 21.9098 42H12.0902C9.83123 42 8 40.1688 8 37.9098C8 36.3606 8.87531 34.9443 10.261 34.2515L13.7082 32.5279C13.8964 32.4338 14.0898 32.3519 14.2872 32.2826ZM17 40C18.6569 40 20 38.6569 20 37C20 35.3431 18.6569 34 17 34C15.3431 34 14 35.3431 14 37C14 38.6569 15.3431 40 17 40ZM21.0004 40H21.9098C23.0642 40 24 39.0642 24 37.9098C24 37.1181 23.5527 36.3944 22.8446 36.0403L21.7724 35.5042C21.9203 35.9765 22 36.479 22 37C22 38.1256 21.6281 39.1643 21.0004 40ZM12.9996 40H12.0902C10.9358 40 10 39.0642 10 37.9098C10 37.1181 10.4473 36.3944 11.1554 36.0403L12.2276 35.5042C12.0797 35.9765 12 36.479 12 37C12 38.1256 12.3719 39.1643 12.9996 40Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);