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="M24 16C22.8954 16 22 16.8954 22 18C22 19.1046 22.8954 20 24 20C25.1046 20 26 19.1046 26 18C26 16.8954 25.1046 16 24 16ZM20 18C20 15.7909 21.7909 14 24 14C26.2091 14 28 15.7909 28 18C28 20.2091 26.2091 22 24 22C21.7909 22 20 20.2091 20 18Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.0677 25.9495C20.3838 24.6961 22.1588 24 24 24C25.8412 24 27.6162 24.6961 28.9323 25.9495C30.25 27.2045 31 28.9174 31 30.7143V34.1429C31 34.6951 30.5523 35.1429 30 35.1429H28.4402L27.385 41.1724C27.3013 41.6509 26.8858 42 26.4 42H21.6C21.1142 42 20.6987 41.6509 20.615 41.1724L19.5598 35.1429H18C17.4477 35.1429 17 34.6951 17 34.1429V30.7143C17 28.9174 17.75 27.2045 19.0677 25.9495ZM24 26C22.6586 26 21.3814 26.5079 20.447 27.3978C19.5143 28.2861 19 29.4802 19 30.7143V33.1429H20.4C20.8858 33.1429 21.3013 33.492 21.385 33.9705L22.4402 40H25.5598L26.615 33.9705C26.6987 33.492 27.1142 33.1429 27.6 33.1429H29V30.7143C29 29.4802 28.4857 28.2861 27.553 27.3978C26.6186 26.5079 25.3414 26 24 26Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M23.3979 6.20156C23.7543 5.9328 24.2457 5.93281 24.6021 6.2016L41.0324 18.5927C41.0596 18.6132 41.0858 18.6351 41.1107 18.6583C41.6384 19.1482 41.9563 19.823 41.9983 20.5417C41.9994 20.5611 42 20.5806 42 20.6V39.5221L42 39.5252C41.998 40.1809 41.7366 40.8092 41.2729 41.2729C40.8092 41.7366 40.1809 41.998 39.5252 42L39.5221 42H8.47787L8.47481 42C7.81907 41.998 7.19076 41.7366 6.72707 41.2729C6.26339 40.8092 6.00201 40.1809 6 39.5252L6 39.5221V20.5985C6 20.579 6.00057 20.5596 6.0017 20.5402C6.04366 19.8214 6.36165 19.1467 6.88926 18.6568C6.91424 18.6336 6.94039 18.6117 6.96761 18.5912L23.3979 6.20156ZM8.22087 20.151C8.09409 20.2815 8.01597 20.4519 8 20.6335V39.5202C8.00068 39.6472 8.05144 39.7689 8.14128 39.8587C8.23117 39.9486 8.35288 39.9994 8.47997 40C8.47966 40 8.48029 40 8.47997 40L39.5191 40C39.5188 40 39.5194 40 39.5191 40C39.6462 39.9994 39.7688 39.9486 39.8587 39.8587C39.9486 39.7688 39.9994 39.6471 40 39.52C40 39.5197 40 39.5203 40 39.52V20.635C39.984 20.4534 39.9059 20.283 39.7791 20.1525L24 8.25247L8.22087 20.151Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);