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="M15 32C14.4477 32 14 32.4477 14 33C14 33.5523 14.4477 34 15 34L33 34C33.5523 34 34 33.5523 34 33C34 32.4477 33.5523 32 33 32L15 32Z" fill="black"/>
<path d="M14 37C14 36.4477 14.4477 36 15 36H27C27.5523 36 28 36.4477 28 37C28 37.5523 27.5523 38 27 38H15C14.4477 38 14 37.5523 14 37Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.9231 15.6154C20.7678 15.2427 20.4037 15 20 15C19.5963 15 19.2322 15.2427 19.0769 15.6154L15.3355 24.5947C15.3294 24.6086 15.3235 24.6226 15.318 24.6368L14.0769 27.6154C13.8645 28.1252 14.1056 28.7107 14.6154 28.9231C15.1252 29.1355 15.7107 28.8944 15.9231 28.3846L16.9167 26H23.0833L24.0769 28.3846C24.2893 28.8944 24.8748 29.1355 25.3846 28.9231C25.8944 28.7107 26.1355 28.1252 25.9231 27.6154L24.682 24.6368C24.6765 24.6226 24.6706 24.6086 24.6645 24.5947L20.9231 15.6154ZM20 18.6L22.25 24H17.75L20 18.6Z" fill="black"/>
<path d="M30 21C30.5523 21 31 21.4477 31 22V24H33C33.5523 24 34 24.4477 34 25C34 25.5523 33.5523 26 33 26H31V28C31 28.5523 30.5523 29 30 29C29.4477 29 29 28.5523 29 28V26H27C26.4477 26 26 25.5523 26 25C26 24.4477 26.4477 24 27 24H29V22C29 21.4477 29.4477 21 30 21Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38 15L28 4H14C11.7909 4 10 5.79086 10 8V40C10 42.2091 11.7909 44 14 44H34C36.2091 44 38 42.2091 38 40V15ZM27 15C27 15.5523 27.4477 16 28 16H36V40C36 41.1046 35.1046 42 34 42H14C12.8954 42 12 41.1046 12 40V8C12 6.89543 12.8954 6 14 6H27V15ZM34.388 14L29 8.07321V14H34.388Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);