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="M8.9778 8.35429C18.7472 5.21452 29.2538 5.21526 39.0227 8.3564C41.5056 9.15478 42.6029 11.9037 41.6666 14.2306L35.3047 30.0405C35.2816 30.0977 35.2585 30.1559 35.235 30.2147C35.0075 30.7852 34.754 31.421 34.3671 31.908C33.8635 32.5419 33.1826 32.8943 32.2547 32.9942C31.7056 33.0534 31.2125 32.6562 31.1534 32.1071C31.0942 31.558 31.4914 31.0649 32.0405 31.0058C32.5173 30.9544 32.6778 30.8192 32.8012 30.664C32.9974 30.4169 33.1434 30.054 33.432 29.3369L39.8112 13.484C40.3543 12.1343 39.6886 10.6714 38.4105 10.2604C29.0396 7.24723 18.9611 7.24652 9.58975 10.2584C8.31157 10.6692 7.64567 12.132 8.18857 13.4817L14.5691 29.3444C14.8552 30.0556 15.0002 30.4163 15.1954 30.6626C15.3184 30.8177 15.4784 30.9528 15.9542 31.0045C16.5032 31.0641 16.9 31.5576 16.8403 32.1066C16.7807 32.6557 16.2872 33.0524 15.7382 32.9928C14.8107 32.892 14.1307 32.539 13.6281 31.905C13.2428 31.4189 12.9901 30.7846 12.7634 30.2156C12.7396 30.1559 12.7161 30.0969 12.6928 30.0389L6.33305 14.2281C5.39705 11.9011 6.49473 9.15232 8.9778 8.35429ZM18.6424 12.0657C20.3409 11.3621 22.1614 11 24 11C25.8385 11 27.659 11.3621 29.3575 12.0657C31.0561 12.7693 32.5994 13.8005 33.8995 15.1005C34.29 15.491 34.29 16.1242 33.8995 16.5147C33.5089 16.9052 32.8758 16.9052 32.4852 16.5147C31.3709 15.4004 30.0481 14.5165 28.5922 13.9134C27.1362 13.3104 25.5758 13 24 13C22.4241 13 20.8637 13.3104 19.4078 13.9134C17.9518 14.5165 16.629 15.4004 15.5147 16.5147C15.1241 16.9052 14.491 16.9052 14.1005 16.5147C13.7099 16.1242 13.7099 15.491 14.1005 15.1005C15.4005 13.8005 16.9438 12.7693 18.6424 12.0657ZM18.0097 16.9927C19.7437 15.6955 21.8519 14.9962 24.0174 15C26.1829 15.0038 28.2887 15.7104 30.0181 17.0136C30.4592 17.346 30.5473 17.973 30.2149 18.4141C29.8826 18.8552 29.2556 18.9433 28.8145 18.6109C27.4309 17.5683 25.7463 17.003 24.0139 17C22.2815 16.997 20.595 17.5564 19.2078 18.5941C18.7655 18.925 18.1388 18.8347 17.808 18.3924C17.4772 17.9502 17.5675 17.3235 18.0097 16.9927ZM18.9999 23.0639V24.8708C19.0485 24.8517 19.0981 24.8327 19.1488 24.8137C20.2534 24.3995 21.8721 24 24 24C26.1278 24 27.7465 24.3995 28.8511 24.8137C28.9018 24.8327 28.9514 24.8517 29 24.8708V23.0639C28.7943 22.9557 28.5106 22.822 28.1488 22.6863C27.2534 22.3505 25.8721 22 24 22C22.1278 22 20.7465 22.3505 19.8511 22.6863C19.4893 22.822 19.2056 22.9557 18.9999 23.0639ZM30 22.5L30.6 21.7C30.8518 21.8889 31 22.1852 31 22.5V26.7889C31 27.776 30.7078 28.7411 30.1602 29.5624L29.5038 30.547C29.1753 31.0398 29 31.6188 29 32.2111V35.9792C29 37.2038 28.5506 38.3858 27.737 39.301C26.9856 40.1464 26.0191 40.6723 25 40.8789V41C25 41.7693 25.8374 42.246 26.4989 41.8533L28.6167 40.5958C30.6801 39.3707 33.3449 40.0275 34.6026 42.0713L34.8516 42.4759C35.1411 42.9463 34.9944 43.5622 34.524 43.8517C34.0537 44.1411 33.4377 43.9945 33.1483 43.5241L32.8993 43.1195C32.214 42.0059 30.7621 41.648 29.6377 42.3155L27.52 43.573C25.5253 44.7573 23 43.3198 23 41V40.8789C21.9808 40.6723 21.0143 40.1464 20.2629 39.301C19.4493 38.3858 18.9999 37.2038 18.9999 35.9792V32.2111C18.9999 31.6188 18.8246 31.0398 18.4961 30.547L17.8397 29.5624C17.2921 28.7411 16.9999 27.776 16.9999 26.7889V22.5C16.9999 22.1852 17.1481 21.8889 17.3999 21.7L17.9999 22.5C17.3999 21.7 17.3996 21.7003 17.3999 21.7L17.4033 21.6975L17.4075 21.6944L17.418 21.6867C17.4261 21.6808 17.4361 21.6736 17.4482 21.6651C17.4724 21.6481 17.5047 21.626 17.545 21.5995C17.6258 21.5465 17.739 21.476 17.8847 21.394C18.1761 21.2301 18.5975 21.0204 19.1488 20.8137C20.2534 20.3995 21.8721 20 24 20C26.1278 20 27.7465 20.3995 28.8511 20.8137C29.4024 21.0204 29.8238 21.2301 30.1152 21.394C30.2609 21.476 30.3741 21.5465 30.4549 21.5995C30.4952 21.626 30.5275 21.6481 30.5517 21.6651C30.5638 21.6736 30.5738 21.6808 30.5819 21.6867L30.5924 21.6944L30.5966 21.6975L30.5984 21.6988L30.6 21.7C30.6003 21.7003 30.6 21.7 30 22.5ZM28.9879 27.0576C28.7832 26.9505 28.5035 26.8193 28.1488 26.6863C27.2534 26.3505 25.8721 26 24 26C22.1278 26 20.7465 26.3505 19.8511 26.6863C19.4964 26.8193 19.2167 26.9505 19.012 27.0576C19.0567 27.5551 19.2252 28.0351 19.5038 28.453L20.1602 29.4376C20.7078 30.2589 20.9999 31.224 20.9999 32.2111V35.9792C20.9999 36.7139 21.2696 37.4231 21.7577 37.9723C22.9511 39.3148 25.0488 39.3148 26.2422 37.9723C26.7303 37.4231 27 36.7139 27 35.9792V32.2111C27 31.224 27.2921 30.2589 27.8397 29.4376L28.4961 28.453C28.7747 28.0351 28.9432 27.5551 28.9879 27.0576ZM24 31C24.5522 31 25 31.4477 25 32V36C25 36.5523 24.5522 37 24 37C23.4477 37 23 36.5523 23 36V32C23 31.4477 23.4477 31 24 31Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);