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="M6 41C6 41.5523 6.44772 42 7 42H42V40H8V18H8.87117C10.8868 18 12.8924 18.6123 14.7353 19.8148C16.5811 21.0192 18.2174 22.7864 19.5 25.0011C20.9186 27.4509 22.7615 29.4633 24.9025 30.8604C27.0465 32.2593 29.4283 33.0002 31.8597 33H38.3663L35.2927 36.0748C34.9023 36.4654 34.9024 37.0986 35.293 37.489C35.6836 37.8795 36.3168 37.8793 36.7073 37.4887L41.4873 32.7067C41.8776 32.3162 41.8776 31.6833 41.4873 31.2928L36.7073 26.5108C36.3168 26.1202 35.6836 26.1201 35.293 26.5105C34.9024 26.901 34.9023 27.5341 35.2927 27.9247L38.3667 31H31.8596C29.844 31.0001 27.8383 30.3879 25.9954 29.1854C24.1496 27.981 22.5133 26.2137 21.2308 23.9988C19.8121 21.5492 17.9693 19.5368 15.8282 18.1398C13.6843 16.7409 11.3026 16 8.87115 16H8V6H6V41Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M31.65 6C31.0977 6 30.65 6.44772 30.65 7C30.65 7.5013 31.0189 7.91645 31.5 7.98882V9.48157C30.561 9.63643 29.6942 10.0058 28.9518 10.5376L27.9642 9.55L28.1071 9.40711C28.4976 9.01658 28.4976 8.38342 28.1071 7.99289C27.7166 7.60237 27.0834 7.60237 26.6929 7.99289L24.9929 9.69289C24.6024 10.0834 24.6024 10.7166 24.9929 11.1071C25.3834 11.4976 26.0166 11.4976 26.4071 11.1071L26.55 10.9642L27.5376 11.9518C27.0058 12.6942 26.6364 13.561 26.4816 14.5H24.9888C24.9165 14.0189 24.5013 13.65 24 13.65C23.4477 13.65 23 14.0977 23 14.65V16.35C23 16.9023 23.4477 17.35 24 17.35C24.5013 17.35 24.9165 16.9811 24.9888 16.5H26.4816C26.6364 17.439 27.0058 18.3058 27.5376 19.0482L26.55 20.0358L26.4071 19.8929C26.0166 19.5024 25.3834 19.5024 24.9929 19.8929C24.6024 20.2834 24.6024 20.9166 24.9929 21.3071L26.6929 23.0071C27.0834 23.3976 27.7166 23.3976 28.1071 23.0071C28.4976 22.6166 28.4976 21.9834 28.1071 21.5929L27.9642 21.45L28.9518 20.4624C29.6942 20.9942 30.561 21.3636 31.5 21.5184V23.0112C31.0189 23.0835 30.65 23.4987 30.65 24C30.65 24.5523 31.0977 25 31.65 25H33.35C33.9023 25 34.35 24.5523 34.35 24C34.35 23.4987 33.9811 23.0835 33.5 23.0112V21.5184C34.6467 21.3293 35.6857 20.8204 36.5221 20.0863L37.8858 21.45L37.7429 21.5929C37.3524 21.9834 37.3524 22.6166 37.7429 23.0071C38.1334 23.3976 38.7666 23.3976 39.1571 23.0071L40.8571 21.3071C41.2476 20.9166 41.2476 20.2834 40.8571 19.8929C40.4666 19.5024 39.8334 19.5024 39.4429 19.8929L39.3 20.0358L37.795 18.5308C38.149 17.9136 38.3983 17.2285 38.5184 16.5H40.0112C40.0835 16.9811 40.4987 17.35 41 17.35C41.5523 17.35 42 16.9023 42 16.35V14.65C42 14.0977 41.5523 13.65 41 13.65C40.4987 13.65 40.0835 14.0189 40.0112 14.5H38.5184C38.3636 13.561 37.9942 12.6942 37.4624 11.9518L38.45 10.9642L38.5929 11.1071C38.9834 11.4976 39.6166 11.4976 40.0071 11.1071C40.3976 10.7166 40.3976 10.0834 40.0071 9.69289L38.3071 7.99289C37.9166 7.60237 37.2834 7.60237 36.8929 7.99289C36.5024 8.38342 36.5024 9.01658 36.8929 9.40711L37.0358 9.55L36.0482 10.5376C35.3058 10.0058 34.439 9.63643 33.5 9.48157V7.98882C33.9811 7.91645 34.35 7.5013 34.35 7C34.35 6.44772 33.9023 6 33.35 6H31.65ZM32.5 19.6C30.2356 19.6 28.4 17.7644 28.4 15.5C28.4 13.2356 30.2356 11.4 32.5 11.4C34.7644 11.4 36.6 13.2356 36.6 15.5C36.6 17.7644 34.7644 19.6 32.5 19.6Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);