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="M16 9V12H13V14H16V17H18V14H21V12H18V9H16Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 6C11.3431 6 10 7.34315 10 9V10H6V29H28V10H24V9C24 7.34315 22.6569 6 21 6H13ZM21 20C22.6569 20 24 18.6569 24 17V16H26V27H21V21H13V27H8V16H10V17C10 18.6569 11.3431 20 13 20H21ZM12 9C12 8.44772 12.4477 8 13 8H21C21.5523 8 22 8.44772 22 9V17C22 17.5523 21.5523 18 21 18H13C12.4477 18 12 17.5523 12 17V9ZM8 12H10V14H8V12ZM26 14H24V12H26V14ZM19 23V27H15V23H19Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30 28C30 25.7902 31.7902 24 34 24C36.2098 24 38 25.7902 38 28C38 30.2098 36.2098 32 34 32C31.7902 32 30 30.2098 30 28ZM34 26C32.8948 26 32 26.8948 32 28C32 29.1052 32.8948 30 34 30C35.1052 30 36 29.1052 36 28C36 26.8948 35.1052 26 34 26Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M34 33C31.33 33 26 34.4618 26 37.3636V40H17C16.2714 40 15.7984 39.7367 15.4974 39.3981C15.1801 39.0412 15 38.5369 15 38V34.4142L18.2929 37.7071L19.7071 36.2929L14 30.5858L8.29289 36.2929L9.70711 37.7071L13 34.4142V38C13 38.9631 13.3199 39.9588 14.0026 40.7269C14.7016 41.5133 15.7286 42 17 42H42V37.3636C42 34.4618 36.67 33 34 33ZM28.2936 36.867C28.0106 37.1519 28 37.3082 28 37.3636V40H40V37.3636C40 37.3082 39.9894 37.1519 39.7064 36.867C39.4052 36.5637 38.9011 36.2325 38.2004 35.9263C36.788 35.3091 35.0608 35 34 35C32.9392 35 31.212 35.3091 29.7996 35.9263C29.0989 36.2325 28.5948 36.5637 28.2936 36.867Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);