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="M33.9299 24.0801H40.68C42.5136 24.0801 44 22.5937 44 20.7601C44 18.9266 42.5136 17.4402 40.68 17.4402H23.7544L26.0402 16.6042C28.2411 15.7993 28.8747 12.9892 27.2321 11.3177C26.3479 10.4179 25.0201 10.1166 23.8342 10.5467L11.8501 14.8924C7.13807 16.6011 4 21.0771 4 26.0894C4 32.6674 9.3325 37.9999 15.9105 37.9999H26.974C28.6308 37.9999 29.974 36.6568 29.974 34.9999V34.36C29.974 34.0093 29.9138 33.6727 29.8032 33.36H30.3448C32.0016 33.36 33.3448 32.0168 33.3448 30.36V29.72C33.3448 29.1357 33.1777 28.5903 32.8887 28.1292C33.6241 27.5824 34.1006 26.7069 34.1006 25.72V25.0801C34.1006 24.7295 34.0404 24.3929 33.9299 24.0801ZM42 20.7601C42 20.0311 41.409 19.4402 40.68 19.4402H23.7544C21.5185 19.4402 20.9676 16.3298 23.0674 15.5619L25.3532 14.7259C26.1885 14.4204 26.429 13.3539 25.8056 12.7195C25.47 12.378 24.9661 12.2637 24.516 12.4269L12.532 16.7726C8.61113 18.1944 6 21.9188 6 26.0894C6 31.5628 10.4371 35.9999 15.9105 35.9999H26.974C27.5262 35.9999 27.9739 35.5522 27.9739 34.9999V34.36C27.9739 33.8077 27.5262 33.36 26.9739 33.36H23.238V31.36H30.3448C30.8971 31.36 31.3448 30.9122 31.3448 30.36V29.72C31.3448 29.1678 30.8971 28.72 30.3448 28.72H25.5178V26.72H31.1006C31.6529 26.72 32.1006 26.2723 32.1006 25.72V25.0801C32.1006 24.5278 31.6529 24.0801 31.1006 24.0801H25.5178V22.0801H36.0028C36.0009 22.0536 36 22.0269 36 22C36 21.1716 36.8954 20.5 38 20.5C39.1046 20.5 40 21.1716 40 22C40 22.0269 39.9991 22.0536 39.9972 22.0801H40.68C41.409 22.0801 42 21.4891 42 20.7601Z" fill="black"/>
<path d="M41.0033 30.1404C41.0033 31.7404 39.6833 32.9976 38.0033 32.9976C36.3233 32.9976 35.0033 31.7404 35.0033 30.1404C35.0033 28.5404 38.0033 24.9976 38.0033 24.9976C38.0033 24.9976 41.0033 28.6547 41.0033 30.1404Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);