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="M38 10C37.4477 10 37 10.4477 37 11C37 11.5523 37.4477 12 38 12C39.6569 12 41 13.3431 41 15V16.5909C41 17.9214 39.9214 19 38.5909 19H38C37.4477 19 37 19.4477 37 20C37 20.5523 37.4477 21 38 21C40.2091 21 42 22.7909 42 25V28C42 28.5523 42.4477 29 43 29C43.5523 29 44 28.5523 44 28V25C44 22.9294 42.9512 21.1039 41.3559 20.0255C42.3585 19.2173 43 17.979 43 16.5909V15C43 12.2386 40.7614 10 38 10Z" fill="black"/>
<path d="M31 20C31 18.3431 32.3431 17 34 17C34.5523 17 35 16.5523 35 16C35 15.4477 34.5523 15 34 15C31.2386 15 29 17.2386 29 20V21.8182C29 24.5796 31.2386 26.8182 34 26.8182H37C37.5523 26.8182 38 27.2659 38 27.8182V28C38 28.5523 38.4477 29 39 29C39.5523 29 40 28.5523 40 28V27.8182C40 26.1613 38.6569 24.8182 37 24.8182H34C32.3431 24.8182 31 23.475 31 21.8182V20Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 33C4 31.3431 5.34315 30 7 30H33C34.6569 30 36 31.3431 36 33V35C36 36.6569 34.6569 38 33 38H7C5.34315 38 4 36.6569 4 35V33ZM7 32C6.44772 32 6 32.4477 6 33V35C6 35.5523 6.44772 36 7 36H33C33.5523 36 34 35.5523 34 35V33C34 32.4477 33.5523 32 33 32H7Z" fill="black"/>
<path d="M39 31C39.5523 31 40 31.4477 40 32V36C40 36.5523 39.5523 37 39 37C38.4477 37 38 36.5523 38 36V32C38 31.4477 38.4477 31 39 31Z" fill="black"/>
<path d="M43 31C43.5523 31 44 31.4477 44 32V36C44 36.5523 43.5523 37 43 37C42.4477 37 42 36.5523 42 36V32C42 31.4477 42.4477 31 43 31Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);