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="M29 9C29 11.7614 26.7614 14 24 14C21.2386 14 19 11.7614 19 9C19 6.23858 21.2386 4 24 4C26.7614 4 29 6.23858 29 9ZM27 9C27 10.6569 25.6569 12 24 12C22.3431 12 21 10.6569 21 9C21 7.34315 22.3431 6 24 6C25.6569 6 27 7.34315 27 9Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 16C12.0698 16 11.259 16.5053 10.7215 17.0429C10.2017 17.5627 9.71429 18.3384 9.71429 19.1429C9.71429 19.6834 9.97834 20.114 10.1821 20.3857C10.3862 20.6578 10.6437 20.9152 10.8423 21.1136L10.8643 21.1357C11.0146 21.286 11.1351 21.4077 11.2313 21.5153C11.057 21.6015 10.851 21.6904 10.6067 21.7959L10.6057 21.7964C10.5138 21.836 10.4165 21.878 10.3135 21.9231C9.88962 22.1086 9.36699 22.3475 8.94654 22.654C8.54617 22.946 8 23.4739 8 24.2857C8 24.9559 8.31691 25.4446 8.6732 25.7786C8.97772 26.0641 9.3562 26.2766 9.61516 26.422L9.6526 26.443C9.96517 26.6188 10.1356 26.7211 10.2446 26.8233C10.2661 26.8434 10.2787 26.8579 10.2856 26.8668C10.2825 27.0267 10.1978 27.1737 9.72146 27.65L9.66346 27.7077C9.27501 28.093 8.57143 28.7908 8.57143 29.8571C8.57143 30.5654 8.96309 31.1026 9.31976 31.4504C9.686 31.8075 10.1383 32.0878 10.5352 32.2961C10.9408 32.5091 11.3389 32.6728 11.631 32.7823C11.7784 32.8376 11.9022 32.8803 11.9906 32.9097C12.0349 32.9244 12.0705 32.9358 12.096 32.9439L12.1267 32.9534L12.136 32.9563L12.1391 32.9572L12.1412 32.9578L13.0991 33.2452L13.6737 31.3295L12.7159 31.0422L12.7141 31.0416L12.6969 31.0363C12.6806 31.0311 12.6549 31.0229 12.621 31.0116C12.5532 30.9891 12.4537 30.9548 12.3333 30.9097C12.0897 30.8183 11.7735 30.6874 11.4648 30.5253C11.1474 30.3587 10.8854 30.1836 10.716 30.0184C10.6132 29.9182 10.5808 29.8583 10.5718 29.8379C10.5782 29.6815 10.6689 29.5311 11.1357 29.0643L11.1937 29.0066C11.5821 28.6213 12.2857 27.9235 12.2857 26.8571C12.2857 26.187 11.9688 25.6982 11.6125 25.3642C11.308 25.0787 10.9295 24.8662 10.6706 24.7209L10.6331 24.6999C10.3292 24.5289 10.1597 24.4275 10.0503 24.3281C10.0702 24.3114 10.0948 24.292 10.1249 24.2701C10.3473 24.1079 10.6818 23.945 11.1151 23.7554C11.1874 23.7238 11.2639 23.6909 11.3431 23.6568C11.6847 23.5097 12.0755 23.3415 12.3831 23.1685C12.5764 23.0597 12.8061 22.9125 12.9976 22.7158C13.191 22.5173 13.4286 22.18 13.4286 21.7143C13.4286 21.1737 13.1645 20.7432 12.9607 20.4714C12.7567 20.1994 12.4991 19.9419 12.3006 19.7435L12.2785 19.7215C12.0512 19.4941 11.8919 19.332 11.7821 19.1857C11.753 19.1469 11.7342 19.1178 11.7223 19.0977C11.7236 19.0921 11.7253 19.086 11.7271 19.0794C11.7398 19.0351 11.7622 18.9766 11.7985 18.9067C11.872 18.765 11.987 18.6057 12.1357 18.4571C12.4553 18.1375 12.7873 18 13 18H14V16H13ZM12.1412 32.9578L12.398 32.1019L12.1745 32.8474C12.162 32.8888 12.1543 32.9147 12.1494 32.9309C12.1413 32.9579 12.1413 32.9578 12.1412 32.9578Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.7647 16C17.4338 16 16.2621 16.8768 15.8866 18.1535L14.1219 24.1535C13.6952 25.6043 14.415 27.1458 15.8012 27.7501L17 28.2726V31.7225L17 31.7333L17 41.2666C17 42.8524 18.3961 43.9395 19.8701 43.9974C21.3401 44.0552 22.8224 43.0907 22.9863 41.5279L23.8808 33H24.1191L25.0136 41.5279C25.1776 43.0907 26.6598 44.0552 28.1299 43.9974C29.6038 43.9395 31 42.8524 31 41.2666V32.0088L31 32V28.2726L32.1987 27.7501C33.585 27.1458 34.3048 25.6043 33.8781 24.1535L32.1134 18.1535C31.7378 16.8768 30.5661 16 29.2353 16H18.7647ZM28.6497 28.9615C28.7659 28.9283 28.883 28.8916 29 28.8524V31.9911L29 32V41.2666C29 41.5344 28.7139 41.9729 28.0513 41.999C27.3849 42.0252 27.0324 41.6023 27.0027 41.3192L26.0142 31.8957C25.9608 31.3866 25.5316 31 25.0197 31H22.9802C22.4683 31 22.0391 31.3866 21.9857 31.8957L20.9972 41.3192C20.9675 41.6023 20.615 42.0252 19.9486 41.999C19.2861 41.9729 19 41.5344 19 41.2666L19 31.7333L19 31.7297V28.8524C19.117 28.8916 19.2341 28.9283 19.3503 28.9615C19.8267 29.0977 20.4191 29.2149 20.984 29.1073C21.2848 29.05 21.5983 28.9252 21.8733 28.6907C22.1503 28.4546 22.3371 28.1509 22.4487 27.8162C22.6997 27.0632 22.9585 26.1007 22.5388 25.1564C22.1221 24.2188 21.1745 23.5928 19.8714 23.0715L18.9429 22.7001L18.2001 24.5571L19.1286 24.9285C20.3255 25.4072 20.6279 25.7812 20.7112 25.9686C20.7902 26.1464 20.8 26.4277 20.5631 27.1483C20.4525 27.1558 20.2418 27.1362 19.8997 27.0385C19.5234 26.931 19.1025 26.7641 18.648 26.576L18.453 26.495C18.0758 26.338 17.6723 26.17 17.3162 26.0513L16.3675 25.7351L16.3572 25.7662C16.0594 25.5166 15.926 25.1074 16.0406 24.7178L17.8053 18.7178C17.9305 18.2923 18.3211 18 18.7647 18H29.2353C29.6789 18 30.0695 18.2923 30.1946 18.7178L31.9593 24.7178C32.0739 25.1073 31.9405 25.5165 31.6428 25.7662L31.6325 25.7351L30.6838 26.0513C30.3277 26.17 29.9242 26.338 29.547 26.495L29.352 26.576C28.8975 26.7641 28.4766 26.931 28.1003 27.0385C27.7582 27.1362 27.5475 27.1558 27.4369 27.1483C27.2 26.4277 27.2098 26.1464 27.2888 25.9686C27.3721 25.7812 27.6745 25.4072 28.8714 24.9285L29.7999 24.5571L29.0571 22.7001L28.1286 23.0715C26.8255 23.5928 25.8779 24.2188 25.4612 25.1564C25.0415 26.1007 25.3003 27.0632 25.5513 27.8162C25.6629 28.1509 25.8497 28.4546 26.1267 28.6907C26.4017 28.9252 26.7152 29.05 27.016 29.1073C27.5809 29.2149 28.1733 29.0977 28.6497 28.9615Z" fill="black"/>
<path d="M37.2785 17.0429C36.741 16.5053 35.9302 16 35 16H34V18H35C35.2127 18 35.5447 18.1375 35.8643 18.4571C36.013 18.6057 36.128 18.765 36.2015 18.9067C36.2378 18.9766 36.2602 19.0351 36.2729 19.0794C36.2747 19.086 36.2764 19.0921 36.2777 19.0977C36.2658 19.1178 36.247 19.1469 36.2179 19.1857C36.1081 19.332 35.9488 19.4941 35.7215 19.7215L35.6994 19.7435C35.5009 19.9419 35.2433 20.1994 35.0393 20.4714C34.8355 20.7432 34.5714 21.1737 34.5714 21.7143C34.5714 22.18 34.809 22.5173 35.0024 22.7158C35.1939 22.9125 35.4236 23.0597 35.6169 23.1685C35.9245 23.3415 36.3153 23.5097 36.6569 23.6568C36.6668 23.661 36.6766 23.6653 36.6865 23.6695C36.7552 23.6991 36.8217 23.7278 36.8849 23.7554C37.3182 23.945 37.6527 24.1079 37.8751 24.2701C37.9052 24.292 37.9298 24.3114 37.9497 24.3281C37.8403 24.4275 37.6708 24.5289 37.3669 24.6999L37.3295 24.7209C37.0705 24.8662 36.692 25.0787 36.3875 25.3642C36.0312 25.6982 35.7143 26.187 35.7143 26.8571C35.7143 27.9235 36.4179 28.6213 36.8063 29.0066L36.8643 29.0643C37.3311 29.5311 37.4218 29.6815 37.4282 29.8379C37.4192 29.8583 37.3868 29.9182 37.284 30.0184C37.1146 30.1836 36.8526 30.3587 36.5352 30.5253C36.2265 30.6874 35.9103 30.8183 35.6667 30.9097C35.5463 30.9548 35.4468 30.9891 35.379 31.0116C35.3451 31.0229 35.3194 31.0311 35.3031 31.0363L35.2859 31.0416L35.2841 31.0422L34.3263 31.3295L34.9009 33.2452L35.8609 32.9572L35.864 32.9563L35.8733 32.9534L35.904 32.9439C35.9295 32.9358 35.9651 32.9244 36.0094 32.9097C36.0978 32.8803 36.2215 32.8376 36.369 32.7823C36.6611 32.6728 37.0592 32.5091 37.4648 32.2961C37.8617 32.0878 38.314 31.8075 38.6802 31.4504C39.0369 31.1026 39.4286 30.5654 39.4286 29.8571C39.4286 28.7908 38.725 28.093 38.3365 27.7077L38.2785 27.65C37.8022 27.1737 37.7175 27.0267 37.7144 26.8668C37.7213 26.8579 37.7339 26.8434 37.7554 26.8233C37.8644 26.7211 38.0348 26.6188 38.3474 26.443L38.3848 26.422C38.6438 26.2766 39.0223 26.0641 39.3268 25.7786C39.6831 25.4446 40 24.9559 40 24.2857C40 23.4739 39.4538 22.946 39.0535 22.654C38.633 22.3475 38.1104 22.1086 37.6865 21.9231C37.5834 21.878 37.4861 21.836 37.3942 21.7963C37.1499 21.6908 36.943 21.6015 36.7687 21.5153C36.8649 21.4077 36.9854 21.286 37.1357 21.1357L37.1577 21.1136C37.3562 20.9152 37.6138 20.6577 37.8179 20.3857C38.0217 20.114 38.2857 19.6834 38.2857 19.1429C38.2857 18.3384 37.7983 17.5627 37.2785 17.0429Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);