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 fill-rule="evenodd" clip-rule="evenodd" d="M39 8H9C8.44771 8 8 8.44772 8 9V39C8 39.5523 8.44772 40 9 40H39C39.5523 40 40 39.5523 40 39V9C40 8.44771 39.5523 8 39 8ZM9 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 6H9Z" fill="black"/>
<path d="M19 20C19 21.6575 17.6575 23 16 23C14.3425 23 13 21.6575 13 20C13 18.3425 14.3425 17 16 17C17.6575 17 19 18.3425 19 20Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.2561 27.2407C12.0469 27.4513 12 27.6089 12 27.7273V31H10V27.7273C10 26.9388 10.3695 26.3021 10.8371 25.8313C11.2955 25.3697 11.8869 25.0237 12.4738 24.7672C13.6421 24.2566 15.0285 24 16 24C16.9715 24 18.3579 24.2566 19.5262 24.7672C20.1131 25.0237 20.7045 25.3697 21.1629 25.8313C21.6305 26.3021 22 26.9388 22 27.7273V31H20V27.7273C20 27.6089 19.9531 27.4513 19.7439 27.2407C19.5256 27.0209 19.1799 26.7985 18.7253 26.5998C17.8109 26.2002 16.6973 26 16 26C15.3027 26 14.1891 26.2002 13.2747 26.5998C12.8201 26.7985 12.4744 27.0209 12.2561 27.2407Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M28.2561 27.2407C28.0469 27.4513 28 27.6089 28 27.7273V31H26V27.7273C26 26.9388 26.3695 26.3021 26.8371 25.8313C27.2955 25.3697 27.8869 25.0237 28.4738 24.7672C29.6421 24.2566 31.0285 24 32 24C32.9715 24 34.3579 24.2566 35.5262 24.7672C36.1131 25.0237 36.7045 25.3697 37.1629 25.8313C37.6305 26.3021 38 26.9388 38 27.7273V31H36V27.7273C36 27.6089 35.9531 27.4513 35.7439 27.2407C35.5256 27.0209 35.1799 26.7985 34.7253 26.5998C33.8109 26.2002 32.6973 26 32 26C31.3027 26 30.1891 26.2002 29.2747 26.5998C28.8201 26.7985 28.4744 27.0209 28.2561 27.2407Z" fill="black"/>
<path d="M35 20C35 21.6575 33.6575 23 32 23C30.3425 23 29 21.6575 29 20C29 18.3425 30.3425 17 32 17C33.6575 17 35 18.3425 35 20Z" fill="black"/>
<path d="M27 18C27 19.6575 25.6575 21 24 21C22.3425 21 21 19.6575 21 18C21 16.3425 22.3425 15 24 15C25.6575 15 27 16.3425 27 18Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.6972 24.9952C22.4138 25.0229 22.3163 25.0872 22.2459 25.166L20.7541 23.834C21.2789 23.2461 21.9336 23.0604 22.5025 23.0047C22.8463 22.9711 23.272 22.9828 23.6213 22.9924C23.7638 22.9964 23.8937 23 24 23C24.1063 23 24.2362 22.9964 24.3787 22.9924C24.728 22.9828 25.1537 22.9711 25.4975 23.0047C26.0664 23.0604 26.7211 23.2462 27.2459 23.834L25.7541 25.166C25.6837 25.0872 25.5862 25.0229 25.3028 24.9952C25.1518 24.9805 24.9754 24.9791 24.7491 24.9841C24.6877 24.9855 24.6197 24.9874 24.5474 24.9895C24.3774 24.9944 24.1842 25 24 25C23.8158 25 23.6226 24.9944 23.4526 24.9895C23.3803 24.9874 23.3123 24.9855 23.2509 24.9841C23.0246 24.9791 22.8482 24.9805 22.6972 24.9952Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);