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="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.5 4C8.5 3.44772 8.05228 3 7.5 3H4.5C3.94772 3 3.5 3.44772 3.5 4V20C3.5 20.5523 3.94772 21 4.5 21H7.5C8.05228 21 8.5 20.5523 8.5 20V4ZM5.5 5V19H6.5V5H5.5Z" fill="black"/>
<path d="M9.5 10.6548V20C9.5 20.5523 9.94772 21 10.5 21H13.5C14.0523 21 14.5 20.5523 14.5 20V13.2486C14.4584 13.2495 14.4168 13.2499 14.375 13.2499C13.7194 13.2499 13.0888 13.1426 12.5 12.9444V19H11.5V12.4996C10.6979 12.0487 10.0124 11.4149 9.5 10.6548Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.375 11.7499C14.4168 11.7499 14.4585 11.7494 14.5 11.7482C15.2986 11.7258 16.0437 11.4894 16.6799 11.0943L19.2927 13.7072L20.7069 12.293L18.0941 9.6801C18.5099 9.01074 18.7499 8.2209 18.7499 7.37497C18.7499 4.95874 16.7912 3 14.375 3C11.9587 3 10 4.95874 10 7.37497C10 7.95548 10.1131 8.50958 10.3184 9.01646C10.6465 9.82663 11.2103 10.5161 11.9248 11C12.1072 11.1235 12.2994 11.2336 12.5 11.3289C13.0683 11.5989 13.704 11.7499 14.375 11.7499ZM14.375 9.74995C13.6919 9.74995 13.0762 9.4616 12.643 9C12.2442 8.57517 12 8.00359 12 7.37497C12 6.06331 13.0633 5 14.375 5C15.6866 5 16.7499 6.06331 16.7499 7.37497C16.7499 8.65548 15.7366 9.69929 14.468 9.74816C14.4371 9.74935 14.4061 9.74995 14.375 9.74995Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M16.5 15C15.9477 15 15.5 15.4477 15.5 16V20C15.5 20.5523 15.9477 21 16.5 21H19.5C20.0523 21 20.5 20.5523 20.5 20V16C20.5 15.4477 20.0523 15 19.5 15H16.5ZM17.5 19V17H18.5V19H17.5Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);