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="M31.5694 19.1032L29.28 23.7755L31.821 28.7618C32.775 28.2747 33.8554 28 35 28C38.866 28 42 31.134 42 35C42 38.866 38.866 42 35 42C31.134 42 28 38.866 28 35C28 33.8141 28.2949 32.6971 28.8153 31.7183L24 29.1633L19.1847 31.7183C19.7051 32.6971 20 33.8141 20 35C20 38.866 16.866 42 13 42C9.13401 42 6 38.866 6 35C6 31.134 9.13401 28 13 28C14.1446 28 15.225 28.2747 16.179 28.7618L18.72 23.7755L16.4306 19.1032C15.4168 19.6742 14.2464 20 13 20C9.13401 20 6 16.866 6 13C6 9.13401 9.13401 6 13 6C16.866 6 20 9.13401 20 13C20 14.0746 19.7578 15.0927 19.3251 16.0026L24 18.3878L28.6749 16.0026C28.2422 15.0927 28 14.0746 28 13C28 9.13401 31.134 6 35 6C38.866 6 42 9.13401 42 13C42 16.866 38.866 20 35 20C33.7536 20 32.5832 19.6742 31.5694 19.1032ZM35 18C37.7614 18 40 15.7614 40 13C40 10.2386 37.7614 8 35 8C32.2386 8 30 10.2386 30 13C30 13.7473 30.1639 14.4563 30.4578 15.093L33.3601 13.6122C33.2889 13.4217 33.25 13.2154 33.25 13C33.25 12.0335 34.0335 11.25 35 11.25C35.9665 11.25 36.75 12.0335 36.75 13C36.75 13.9665 35.9665 14.75 35 14.75C34.581 14.75 34.1963 14.6027 33.895 14.3571L32.4516 17.3028C33.1979 17.7457 34.0693 18 35 18ZM17.5422 15.093C17.8361 14.4563 18 13.7473 18 13C18 10.2386 15.7614 8 13 8C10.2386 8 8 10.2386 8 13C8 15.7614 10.2386 18 13 18C13.9307 18 14.8021 17.7457 15.5484 17.3028L14.105 14.3571C13.8037 14.6027 13.419 14.75 13 14.75C12.0335 14.75 11.25 13.9665 11.25 13C11.25 12.0335 12.0335 11.25 13 11.25C13.9665 11.25 14.75 12.0335 14.75 13C14.75 13.2154 14.7111 13.4217 14.6399 13.6122L17.5422 15.093ZM15.2707 30.5442C14.5893 30.1962 13.8176 30 13 30C10.2386 30 8 32.2386 8 35C8 37.7614 10.2386 40 13 40C15.7614 40 18 37.7614 18 35C18 34.1529 17.7894 33.3551 17.4176 32.656L14.5462 34.1796C14.6763 34.4243 14.75 34.7035 14.75 35C14.75 35.9665 13.9665 36.75 13 36.75C12.0335 36.75 11.25 35.9665 11.25 35C11.25 34.0335 12.0335 33.25 13 33.25C13.2862 33.25 13.5563 33.3187 13.7947 33.4405L15.2707 30.5442ZM30.5824 32.656C30.2106 33.3551 30 34.1529 30 35C30 37.7614 32.2386 40 35 40C37.7614 40 40 37.7614 40 35C40 32.2386 37.7614 30 35 30C34.1824 30 33.4107 30.1962 32.7293 30.5442L34.2053 33.4405C34.4437 33.3187 34.7139 33.25 35 33.25C35.9665 33.25 36.75 34.0335 36.75 35C36.75 35.9665 35.9665 36.75 35 36.75C34.0335 36.75 33.25 35.9665 33.25 35C33.25 34.7035 33.3237 34.4243 33.4538 34.1796L30.5824 32.656ZM24.9089 20.1693L29.7924 17.6777C29.8456 17.737 29.8998 17.7953 29.955 17.8526L27.484 22.8955C27.2071 23.4605 27.2123 24.1229 27.498 24.6836L30.1722 29.9312C30.1179 29.983 30.0644 30.0356 30.0117 30.0891L24.9374 27.3966C24.3512 27.0855 23.6488 27.0855 23.0626 27.3966L17.9883 30.0891C17.9356 30.0356 17.8821 29.983 17.8278 29.9312L20.502 24.6836C20.7877 24.1229 20.7929 23.4605 20.516 22.8955L18.045 17.8526C18.1002 17.7953 18.1544 17.737 18.2076 17.6777L23.0911 20.1693C23.662 20.4606 24.338 20.4606 24.9089 20.1693Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);