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="M18.2597 10.1418C21.0006 9.0065 24.0166 8.70945 26.9264 9.28823C29.5625 9.8126 32.0042 11.0345 34 12.8197C35.235 13.9243 35.3406 15.8208 34.236 17.0557C33.1315 18.2907 31.2349 18.3964 30 17.2918C28.8025 16.2207 27.3375 15.4876 25.7558 15.1729C24.01 14.8257 22.2004 15.0039 20.5559 15.6851C18.9113 16.3663 17.5057 17.5198 16.5168 18.9999C15.5278 20.4799 15 22.22 15 24C15 25.78 15.5278 27.5201 16.5168 29.0001C17.5057 30.4802 18.9113 31.6337 20.5559 32.3149C22.2004 32.9961 24.01 33.1743 25.7558 32.8271C26.9206 32.5954 28.022 32.1367 29 31.4833V27H24C22.3431 27 21 25.6569 21 24C21 22.3432 22.3431 21 24 21L32 21C33.6569 21 35 22.3432 35 24V32.9443C35 33.798 34.6363 34.6112 34 35.1803C32.0042 36.9655 29.5625 38.1874 26.9264 38.7118C24.0166 39.2906 21.0006 38.9935 18.2597 37.8582C15.5189 36.7229 13.1762 34.8003 11.528 32.3336C9.87974 29.8668 9 26.9667 9 24C9 21.0333 9.87973 18.1332 11.528 15.6665C13.1762 13.1997 15.5189 11.2771 18.2597 10.1418ZM26.5362 11.2498C24.0144 10.7482 21.4006 11.0056 19.0251 11.9896C16.6497 12.9735 14.6194 14.6398 13.1909 16.7776C11.7624 18.9154 11 21.4289 11 24C11 26.5712 11.7624 29.0846 13.1909 31.2224C14.6194 33.3603 16.6497 35.0265 19.0251 36.0104C21.4006 36.9944 24.0144 37.2518 26.5362 36.7502C28.8209 36.2958 30.937 35.2368 32.6667 33.6896C32.8788 33.4999 33 33.2288 33 32.9443V24C33 23.4477 32.5523 23 32 23L24 23C23.4477 23 23 23.4477 23 24C23 24.5523 23.4477 25 24 25H30C30.5523 25 31 25.4477 31 26V32C31 32.3148 30.8518 32.6112 30.6 32.8C29.2881 33.7839 27.7672 34.4662 26.146 34.7886C24.0122 35.2131 21.8005 34.9953 19.7905 34.1627C17.7805 33.3301 16.0625 31.9202 14.8538 30.1113C13.6451 28.3023 13 26.1756 13 24C13 21.8244 13.6451 19.6977 14.8538 17.8887C16.0625 16.0798 17.7805 14.6699 19.7905 13.8373C21.8005 13.0048 24.0122 12.7869 26.146 13.2114C28.0792 13.5959 29.8697 14.492 31.3333 15.8011C31.745 16.1693 32.3772 16.134 32.7453 15.7224C33.1135 15.3108 33.0783 14.6786 32.6667 14.3104C30.937 12.7633 28.8209 11.7043 26.5362 11.2498Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);