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 d="M36.5 3.58569L40.7071 7.7928C41.0976 8.18332 41.0976 8.81649 40.7071 9.20701C40.3166 9.59754 39.6834 9.59754 39.2929 9.20701L37.5 7.41412V44H35.5V7.41412L33.7071 9.20701C33.3166 9.59754 32.6834 9.59754 32.2929 9.20701C31.9024 8.81649 31.9024 8.18332 32.2929 7.7928L36.5 3.58569Z" fill="black"/>
<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="M27.9129 43.9996C26.5445 43.9996 25.3752 43.0794 25.0218 41.8021C24.9894 41.6847 24.9638 41.5643 24.9455 41.4414C24.9372 41.3852 24.9304 41.3285 24.9252 41.2712L24.1733 32.9999H23.8261L23.0742 41.2712C23.069 41.3285 23.0622 41.3852 23.0539 41.4414C23.0356 41.5643 23.01 41.6847 22.9776 41.8021C22.6242 43.0794 21.4549 43.9996 20.0865 43.9996H19.9997C18.3428 43.9996 16.9997 42.6565 16.9997 40.9996V32.2071C16.0519 31.4996 15.4272 30.3812 15.3919 29.1109L15.1276 19.594C15.0601 17.1663 17.154 15.2392 19.5677 15.5074L23.5583 15.9508C23.8519 15.9834 24.1482 15.9834 24.4418 15.9508L28.3022 15.5218C30.7605 15.2487 32.875 17.2497 32.7378 19.7193L32.2098 29.2218C32.1519 30.2644 31.6983 31.1954 30.9997 31.8723L30.9997 40.9996C30.9997 42.6565 29.6566 43.9996 27.9997 43.9996H27.9129ZM18.9997 32.2071C18.9997 31.576 18.7018 30.9819 18.1961 30.6043C17.7181 30.2476 17.4088 29.6895 17.3911 29.0554L17.1268 19.5385C17.0931 18.3246 18.14 17.3611 19.3469 17.4952L23.3375 17.9386C23.7779 17.9875 24.2223 17.9875 24.6627 17.9386L28.5231 17.5096C29.7522 17.373 30.8094 18.3735 30.7408 19.6083L30.2129 29.1108C30.1839 29.6327 29.9589 30.0959 29.6079 30.436C29.2192 30.8127 28.9997 31.331 28.9997 31.8723L28.9997 40.9996C28.9997 41.5519 28.552 41.9996 27.9997 41.9996H27.9129C27.3957 41.9996 26.9639 41.6052 26.917 41.0902L26.1651 32.8188C26.0714 31.7886 25.2077 30.9999 24.1733 30.9999H23.8261C22.7917 30.9999 21.928 31.7886 21.8343 32.8188L21.0824 41.0902C21.0356 41.6052 20.6037 41.9996 20.0865 41.9996H19.9997C19.4474 41.9996 18.9997 41.5519 18.9997 40.9996V32.2071Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);