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="M13.5164 33.0045C14.7589 36.5011 18.1044 39 22.0321 39H25.9679C30.9407 39 35 34.986 35 30V18C35 13.014 30.9407 9 25.9679 9H22.0321C17.0593 9 13 13.014 13 18C13 22.986 17.0593 27 22.0321 27H25.9679C27.0299 27 28.0511 26.8167 29 26.4797V30C29 31.6425 27.6568 33 25.9679 33H22.0321C20.7057 33 19.5833 32.1585 19.1701 30.9955C18.6153 29.4343 16.9 28.6184 15.3387 29.1732C13.7775 29.7279 12.9616 31.4433 13.5164 33.0045ZM22.0321 37C18.9725 37 16.3674 35.0545 15.401 32.3348C15.216 31.8144 15.488 31.2426 16.0084 31.0577C16.5288 30.8728 17.1006 31.1448 17.2855 31.6652C17.9757 33.6075 19.8402 35 22.0321 35H25.9679C28.7528 35 31 32.7556 31 30V24.9201C31 24.5626 30.8091 24.2323 30.4994 24.0537C30.1896 23.8752 29.8082 23.8756 29.4988 24.0547C28.461 24.6558 27.2554 25 25.9679 25H22.0321C18.153 25 15 21.8706 15 18C15 14.1294 18.153 11 22.0321 11H25.9679C29.8469 11 33 14.1294 33 18V30C33 33.8706 29.8469 37 25.9679 37H22.0321ZM22.0321 21C20.3432 21 19 19.6425 19 18C19 16.3575 20.3432 15 22.0321 15H25.9679C27.6568 15 29 16.3575 29 18C29 19.6425 27.6568 21 25.9679 21H22.0321ZM17 18C17 20.7556 19.2472 23 22.0321 23H25.9679C28.7528 23 31 20.7556 31 18C31 15.2444 28.7528 13 25.9679 13H22.0321C19.2472 13 17 15.2444 17 18Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);