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="M33.2581 31C31.5382 27.4383 28.0381 25 24 25C19.9619 25 16.4618 27.4383 14.7419 31C14.273 31.9709 15.0582 33 16.1363 33L31.8637 33C32.9418 33 33.727 31.9709 33.2581 31ZM24 27C26.8697 27 29.4525 28.5553 30.9778 31L17.0222 31C18.5475 28.5553 21.1303 27 24 27Z" fill="black"/>
<path d="M14.2214 16.3725C14.5389 15.9785 15.1008 15.8838 15.53 16.152L19.53 18.652C19.8224 18.8347 20 19.1552 20 19.5C20 19.8448 19.8224 20.1653 19.53 20.348L15.53 22.848C15.0947 23.1201 14.5241 23.0183 14.2096 22.6126C13.8951 22.2069 13.939 21.6289 14.311 21.2752C14.6835 20.9211 15.163 20.5547 15.5554 20.255C15.7291 20.1222 15.8861 20.0023 16.0088 19.9025C16.2025 19.745 16.3368 19.6215 16.4249 19.5237C16.3274 19.4169 16.1803 19.2842 15.9711 19.1142C15.8651 19.0281 15.7403 18.9309 15.6044 18.8251C15.1949 18.5063 14.6844 18.1088 14.284 17.6981C13.9307 17.3357 13.9038 16.7665 14.2214 16.3725Z" fill="black"/>
<path d="M32.47 16.152C32.8992 15.8838 33.4611 15.9785 33.7786 16.3725C34.0962 16.7665 34.0693 17.3357 33.716 17.6981C33.3156 18.1088 32.8051 18.5063 32.3956 18.825C32.2597 18.9309 32.1349 19.0281 32.0289 19.1142C31.8197 19.2842 31.6726 19.4169 31.5751 19.5237C31.6632 19.6215 31.7975 19.745 31.9912 19.9025C32.114 20.0023 32.2707 20.1221 32.4446 20.2549C32.837 20.5547 33.3165 20.9211 33.689 21.2752C34.0611 21.6289 34.1049 22.2069 33.7904 22.6126C33.4759 23.0183 32.9053 23.1201 32.47 22.848L28.47 20.348C28.1776 20.1653 28 19.8448 28 19.5C28 19.1552 28.1776 18.8347 28.47 18.652L32.47 16.152Z" fill="black"/>
<path d="M26 12.5C26 13.3284 25.3284 14 24.5 14C23.6716 14 23 13.3284 23 12.5C23 11.6716 23.6716 11 24.5 11C25.3284 11 26 11.6716 26 12.5Z" fill="black"/>
<path d="M38 27.5C38 28.3284 37.3284 29 36.5 29C35.6716 29 35 28.3284 35 27.5C35 26.6716 35.6716 26 36.5 26C37.3284 26 38 26.6716 38 27.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M42 24C42 33.9411 33.9411 42 24 42C14.0589 42 6 33.9411 6 24C6 14.0589 14.0589 6 24 6C33.9411 6 42 14.0589 42 24ZM40 24C40 32.8366 32.8366 40 24 40C23.9111 40 23.8223 39.9993 23.7337 39.9978C23.9031 39.7041 24 39.3634 24 39C24 37.8954 23.1046 37 22 37C20.8954 37 20 37.8954 20 39C20 39.1773 20.0231 39.3492 20.0664 39.5129C15.0189 38.2369 10.9266 34.5623 9.07305 29.7727C9.35014 29.9179 9.66548 30 10 30C11.1046 30 12 29.1046 12 28C12 26.8954 11.1046 26 10 26C9.26679 26 8.62574 26.3946 8.27756 26.9829C8.09533 26.0165 8 25.0194 8 24C8 19.2677 10.0545 15.0152 13.3202 12.0859C13.6765 12.636 14.2958 13 15 13C16.1046 13 17 12.1046 17 11C17 10.5531 16.8534 10.1404 16.6057 9.80742C18.8173 8.65282 21.3324 8 24 8C27.1068 8 30.0068 8.88548 32.4613 10.4178C32.177 10.6908 32 11.0747 32 11.5C32 12.3284 32.6716 13 33.5 13C34.0703 13 34.5663 12.6817 34.82 12.2131C38.0042 15.1376 40 19.3357 40 24Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);