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="M32.7071 22.7071C33.0976 22.3166 33.0976 21.6834 32.7071 21.2929C32.3166 20.9024 31.6834 20.9024 31.2929 21.2929L24 28.5858L20.7071 25.2929C20.3166 24.9024 19.6834 24.9024 19.2929 25.2929C18.9024 25.6834 18.9024 26.3166 19.2929 26.7071L24 31.4142L32.7071 22.7071Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38 15V36C38 37.6569 36.6569 39 35 39H17C15.3431 39 14 37.6569 14 36V8C14 6.34315 15.3431 5 17 5H28L38 15ZM28 16C27.4477 16 27 15.5523 27 15V7H17C16.4477 7 16 7.44772 16 8V36C16 36.5523 16.4477 37 17 37H35C35.5523 37 36 36.5523 36 36V16H28ZM29 8.82843L34.1716 14H29V8.82843Z" fill="black"/>
<path d="M12 11V38C12 39.6569 13.3431 41 15 41H34V43H15C12.2386 43 10 40.7614 10 38V11H12Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);