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="M19.7575 32.9704C19.2217 32.8364 18.8959 32.2935 19.0299 31.7577L19.7193 29H17C16.4477 29 16 28.5523 16 28C16 27.4477 16.4477 27 17 27H20.2193L21.0299 23.7577C21.1638 23.2219 21.7067 22.8961 22.2425 23.0301C22.7783 23.164 23.1041 23.707 22.9701 24.2428L22.2808 27H25C25.5523 27 26 27.4477 26 28C26 28.5523 25.5523 29 25 29H21.7808L20.9701 32.2428C20.8362 32.7786 20.2933 33.1043 19.7575 32.9704Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.01446 20.138C9.40179 18.869 10.5901 18 11.9381 18H36V16H29V10H38V18.9623L43.9349 32.6489C44.1322 33.166 43.8657 33.7424 43.3395 33.9363C43.3241 33.942 43.3086 33.9473 43.293 33.9522L43.2941 33.9557L33.5 37L34.5 34.5L41.592 32.3776L36.9848 22.1289L32.1825 35.862C31.7952 37.131 30.6069 38 29.2589 38H7.05433C5.00969 38 3.54321 36.0628 4.13073 34.138L9.01446 20.138ZM6.03573 34.7491L10.9158 20.7595L10.9273 20.7218C11.0522 20.3128 11.4503 20 11.9381 20H35.6105L30.2814 35.2398L30.2697 35.2782C30.1448 35.6872 29.7467 36 29.2589 36H7.05433C6.31672 36 5.87591 35.3365 6.03573 34.7491ZM36 12H31V14H36V12Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);