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="M32 30.0544C32 28.3976 33.3431 27.0544 35 27.0544C36.6569 27.0544 38 28.3976 38 30.0544V43.0001C38 43.5524 37.5523 44.0001 37 44.0001C36.4477 44.0001 36 43.5524 36 43.0001V30.0544C36 29.5022 35.5523 29.0544 35 29.0544C34.4477 29.0544 34 29.5022 34 30.0544V30.3974C34 30.9497 33.5523 31.3974 33 31.3974C32.4477 31.3974 32 30.9497 32 30.3974V30.0544Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.2549 17C16.2792 17 14.701 17.6604 13.6168 18.7173C12.5466 19.7606 12.0138 21.1354 12.0003 22.4908C11.9867 23.8467 12.4928 25.2294 13.5639 26.2803C14.6075 27.3043 16.1212 27.949 18.0253 27.9971L19 28.0218V41.2666C19 41.5344 19.2861 41.9729 19.9487 41.999C20.6151 42.0252 20.9675 41.6023 20.9972 41.3192L21.9748 32H26.0252L27.0028 41.3192C27.0325 41.6023 27.3849 42.0252 28.0513 41.999C28.7139 41.9729 29 41.5344 29 41.2666V19.2482L30.4137 19.8907C31.5172 20.3922 32.2347 21.0315 32.7075 21.6061C33.2286 22.2395 33.7215 23.105 33.8507 24.057L33.8533 24.0762L33.855 24.093C33.9065 24.6051 34.3955 25.0465 35.0214 24.9963C35.6211 24.9482 36.0476 24.4299 36.0035 23.9172C35.9701 23.5542 35.8753 23.1755 35.7403 22.769C35.5251 22.1206 35.133 21.258 34.4221 20.3939C32.9643 18.622 30.2951 17 25.5759 17H18.2549ZM12.2207 17.2852C13.7209 15.8227 15.8201 15 18.2549 15H25.5759C30.7999 15 34.0734 16.8221 35.9666 19.1233C36.864 20.2141 37.3624 21.3071 37.6385 22.1388C37.7992 22.6231 37.943 23.1632 37.9954 23.7373L37.9957 23.7405C38.1475 25.4675 36.778 26.8619 35.1813 26.9899C33.5449 27.1211 32.0446 25.9649 31.8672 24.3137C31.8008 23.8499 31.5334 23.327 31.163 22.8767C31.1139 22.8171 31.0598 22.7552 31 22.6918V41.2666C31 42.8524 29.6038 43.9395 28.1299 43.9974C26.6599 44.0552 25.1776 43.0907 25.0137 41.5279L24.224 34H23.776L22.9863 41.5279C22.8224 43.0907 21.3401 44.0552 19.8701 43.9974C18.3962 43.9395 17 42.8524 17 41.2666L17 29.9268C15.0752 29.697 13.4105 28.9318 12.1631 27.7079C10.6795 26.2521 9.98174 24.3355 10.0004 22.4708C10.019 20.6084 10.7516 18.7174 12.2207 17.2852ZM19 18.9572V26.0397L17.9558 25.9935C16.6304 25.9348 15.7188 25.4839 15.131 24.9072C14.4833 24.2717 14.1481 23.405 14.157 22.5092C14.166 21.6134 14.5191 20.7386 15.1791 20.0952C15.7756 19.5137 16.6778 19.0678 17.9524 19.0071L19 18.9572ZM17 21.238C16.8069 21.3294 16.6708 21.4341 16.5752 21.5273C16.3125 21.7834 16.1608 22.1428 16.1569 22.5292C16.1531 22.9128 16.2945 23.2468 16.5317 23.4796C16.6263 23.5724 16.7737 23.686 17 23.7833V21.238Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 6C22.3431 6 21 7.34315 21 9C21 10.6569 22.3431 12 24 12C25.6569 12 27 10.6569 27 9C27 7.34315 25.6569 6 24 6ZM19 9C19 6.23858 21.2386 4 24 4C26.7614 4 29 6.23858 29 9C29 11.7614 26.7614 14 24 14C21.2386 14 19 11.7614 19 9Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);