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 21.75C16 22.1004 15.6744 22.5 15.125 22.5H13V21H15.125C15.6744 21 16 21.3996 16 21.75Z" fill="black"/>
<path d="M15.125 24.5H13V26H15.125C15.6744 26 16 25.6004 16 25.25C16 24.8996 15.6744 24.5 15.125 24.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9 6C7.34315 6 6 7.34315 6 9V39C6 40.6569 7.34315 42 9 42H39C40.6569 42 42 40.6569 42 39V9C42 7.34315 40.6569 6 39 6H9ZM12 19C11.4477 19 11 19.4477 11 20V27C11 27.2652 11.1054 27.5196 11.2929 27.7071C11.4804 27.8946 11.7348 28 12 28H15.125C16.6467 28 18 26.8326 18 25.25C18 24.5702 17.7503 23.967 17.3448 23.5C17.7503 23.033 18 22.4298 18 21.75C18 20.1674 16.6467 19 15.125 19H12ZM30 20C30 19.4477 30.4477 19 31 19H36C36.5523 19 37 19.4477 37 20C37 20.5523 36.5523 21 36 21H34.5V26H36C36.5523 26 37 26.4477 37 27C37 27.5523 36.5523 28 36 28H31C30.4477 28 30 27.5523 30 27C30 26.4477 30.4477 26 31 26H32.5V21H31C30.4477 21 30 20.5523 30 20ZM22 27V22.7033L23.2407 24.1508C23.4307 24.3724 23.7081 24.5 24 24.5C24.2919 24.5 24.5693 24.3724 24.7593 24.1508L26 22.7033V27C26 27.5523 26.4477 28 27 28C27.5523 28 28 27.5523 28 27V20C28 19.5815 27.7394 19.2073 27.3469 19.0621C26.9545 18.9169 26.5131 19.0315 26.2407 19.3492L24 21.9634L21.7593 19.3492C21.4869 19.0315 21.0455 18.9169 20.6531 19.0621C20.2606 19.2073 20 19.5815 20 20V27C20 27.5523 20.4477 28 21 28C21.5523 28 22 27.5523 22 27Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);