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 20C15.4477 20 15 20.4477 15 21C15 21.5523 15.4477 22 16 22H23C23.5523 22 24 21.5523 24 21C24 20.4477 23.5523 20 23 20H16Z" fill="black"/>
<path d="M15 16C15 15.4477 15.4477 15 16 15H31.5C32.0523 15 32.5 15.4477 32.5 16C32.5 16.5523 32.0523 17 31.5 17H16C15.4477 17 15 16.5523 15 16Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M15 28C15 27.4477 15.4477 27 16 27H20C20.5523 27 21 27.4477 21 28V32C21 32.5523 20.5523 33 20 33H16C15.4477 33 15 32.5523 15 32V28ZM17 31V29H19V31H17Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M28 31C29.6575 31 31 29.6575 31 28C31 26.3425 29.6575 25 28 25C26.3425 25 25 26.3425 25 28C25 29.6575 26.3425 31 28 31ZM28 29C28.5529 29 29 28.5529 29 28C29 27.4471 28.5529 27 28 27C27.4471 27 27 27.4471 27 28C27 28.5529 27.4471 29 28 29Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22 35.1818C22 33.0659 25.9975 32 28 32C30.0025 32 34 33.0659 34 35.1818V39H22V35.1818ZM24.0549 35.2212C24.0305 35.2451 24.0127 35.2645 24 35.2793V37H32V35.2793C31.9873 35.2645 31.9695 35.2451 31.9451 35.2212C31.7814 35.061 31.4647 34.8488 30.9688 34.6382C29.9689 34.2133 28.7352 34 28 34C27.2648 34 26.0311 34.2133 25.0312 34.6382C24.5353 34.8488 24.2186 35.061 24.0549 35.2212Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M17 7C17 5.34315 18.3431 4 20 4H28C29.6569 4 31 5.34315 31 7H35C36.6569 7 38 8.34314 38 10V41C38 42.6569 36.6569 44 35 44H13C11.3431 44 10 42.6569 10 41V10C10 8.34315 11.3431 7 13 7H17ZM28 12C29.6569 12 31 10.6569 31 9H35C35.5523 9 36 9.44772 36 10V41C36 41.5523 35.5523 42 35 42H13C12.4477 42 12 41.5523 12 41V10C12 9.44772 12.4477 9 13 9H17C17 10.6569 18.3431 12 20 12H28ZM20 6C19.4477 6 19 6.44772 19 7V9C19 9.55228 19.4477 10 20 10H28C28.5523 10 29 9.55228 29 9V7C29 6.44772 28.5523 6 28 6H20Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);