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="M4 27.0001C4 26.4478 4.44772 26.0001 5 26.0001L16.5227 26.0001C17.5856 26.0001 18.6445 26.1304 19.6757 26.3882L21.539 26.854C23.099 24.4443 25.4143 22.6169 28.1249 21.6602L32 20.2925V18.9032C32 17.7678 32.3864 16.6663 33.0957 15.7797L36.2191 11.8754C36.3864 11.6662 36.6307 11.5329 36.8971 11.5054C37.1635 11.4778 37.4298 11.5582 37.6364 11.7287L38.0032 12.0313C38.2238 12.2133 38.4119 12.4205 38.5667 12.6456L38.9975 12.0533C39.9822 10.6994 41.8844 10.4134 43.2237 11.4178L43.6 11.7001C43.8921 11.9191 44.0416 12.28 43.9899 12.6415L42.9899 19.6415C42.9474 19.9396 42.7727 20.2026 42.5145 20.3575L37.6953 23.249L33.8656 28.6745C32.4171 30.7266 30.4052 32.315 28.0731 33.2479L26.562 33.8523L25.8787 34.5356C24.941 35.4733 23.6692 36.0001 22.3431 36.0001H21.1623L17.1636 37.3329C15.8381 37.7748 14.4499 38.0001 13.0527 38.0001H5C4.44772 38.0001 4 37.5523 4 37.0001V36L13.0527 36.0001C14.235 36.0001 15.4095 35.8094 16.5312 35.4356L20.6838 34.0514C20.7857 34.0174 20.8925 34.0001 21 34.0001H22.3431C23.1388 34.0001 23.9019 33.684 24.4645 33.1214L25.2929 32.2929C25.3887 32.1972 25.5029 32.1219 25.6286 32.0716L27.3303 31.3909C29.3036 30.6016 31.006 29.2575 32.2316 27.5212L36.183 21.9234C36.2632 21.8098 36.3662 21.7141 36.4855 21.6426L41.0774 18.8874L41.9252 12.9526C41.4881 12.6985 40.9197 12.8106 40.615 13.2297L37.8087 17.0882C37.4839 17.5349 36.8585 17.6336 36.4118 17.3088C35.9652 16.9839 35.8664 16.3585 36.1913 15.9119L36.9028 14.9336C37.0965 14.6672 37.1402 14.3356 37.047 14.0421L34.6574 17.0291C34.2318 17.561 34 18.222 34 18.9032V21.0001C34 21.424 33.7326 21.8019 33.3328 21.943L28.7906 23.5462C26.4417 24.3752 24.4437 25.9769 23.1236 28.0891L22.848 28.5301C22.6183 28.8976 22.1779 29.0753 21.7575 28.9702L19.1906 28.3285C18.3181 28.1104 17.4221 28.0001 16.5227 28.0001L4 28V27.0001Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);