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="M38.707 8.29289C39.0975 8.68342 39.0975 9.31658 38.707 9.70711L28.4141 20H25.5858L22.0858 23.5H12.8215C12.4996 22.4582 12.2481 21.2819 12.1121 19.9472C11.7803 19.9643 11.411 19.9724 11 19.9724C9.83632 19.9724 8.04049 19.8939 7.5 19.5C6.50002 18.1752 6 15.5278 6 15.5278C6 15.5278 8.78698 14.5769 10 14.147C9.9999 10.9231 14.1677 9.08322 16.286 11.7995C16.8123 11.7973 17.412 11.9665 17.9737 12.3112C18.9896 12.9346 19.3748 15.7471 19.1543 17.0195C20.7592 18.9098 22.8122 19.6856 25.4999 19.9724L25.6026 19.9831L37.2928 8.29289C37.6833 7.90237 38.3165 7.90237 38.707 8.29289Z" fill="black"/>
<path d="M28.2967 20.1175L23.5 24.9142V31.6288C26.2318 31.2642 28.5675 30.6974 31.5 29C33.6376 32.9189 35.4286 34.0455 36.3477 34.6236C36.7186 34.8569 36.9475 35.0009 37 35.203C37.1194 35.6627 37.2457 35.9998 37.3444 36.2632C37.4676 36.592 37.5478 36.806 37.5177 37H37C36.4477 37 36 37.4477 36 38C36 38.5523 36.4477 39 37 39H39C39.5523 39 40 38.5523 40 38V33.4771C40 31.5 37 26.2283 37 26.2283L41.5 32C41.905 32.2531 42.4521 31.7669 42 31C41.8112 30.496 41.605 29.8357 41.3715 29.0883C40.2574 25.5215 38.5241 19.9724 35.1188 19.9724C34.6262 19.9724 33.9173 19.9977 33.0829 20.0275C31.6958 20.077 29.9616 20.1389 28.2967 20.1175Z" fill="black"/>
<path d="M21.4308 31.8714C21.4539 31.869 21.477 31.8665 21.5 31.864V25.5H13.5862C14.3933 27.2528 15.3593 28.5221 16.1083 29.5062C16.247 29.6885 16.3785 29.8613 16.5 30.0253C16.9789 30.672 18.3754 34.8306 16.2949 37H16C15.4477 37 15 37.4477 15 38C15 38.5523 15.4477 39 16 39H19C19.4611 39 19.8494 38.6879 19.965 38.2634C19.9657 38.2633 19.9664 38.2633 19.9671 38.2632C19.972 38.2628 19.9765 38.2616 19.9806 38.2595C20.0233 38.238 20.0196 38.1242 20.0112 37.8676C20.0064 37.7201 20 37.5255 20 37.2741V32.0253C20.3184 31.9905 20.629 31.9573 20.9328 31.9248L20.9399 31.924C21.0582 31.9114 21.1755 31.8989 21.2918 31.8864C21.3383 31.8814 21.3846 31.8764 21.4308 31.8714Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);