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 fill-rule="evenodd" clip-rule="evenodd" d="M11 20C11 19.4477 11.4477 19 12 19H15.125C16.6467 19 18 20.1674 18 21.75C18 22.4298 17.7503 23.033 17.3448 23.5C17.7503 23.967 18 24.5702 18 25.25C18 26.8326 16.6467 28 15.125 28H12C11.7348 28 11.4804 27.8946 11.2929 27.7071C11.1054 27.5196 11 27.2652 11 27L11 20ZM15.125 22.5C15.6744 22.5 16 22.1004 16 21.75C16 21.3996 15.6744 21 15.125 21H13V22.5H15.125ZM13 24.5H15.125C15.6744 24.5 16 24.8996 16 25.25C16 25.6004 15.6744 26 15.125 26H13V24.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30 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 20Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22 22.7033L22 27C22 27.5523 21.5523 28 21 28C20.4477 28 20 27.5523 20 27L20 20C20 19.5815 20.2606 19.2073 20.6531 19.0621C21.0455 18.9169 21.4869 19.0315 21.7593 19.3492L24 21.9634L26.2407 19.3492C26.5131 19.0315 26.9545 18.9169 27.3469 19.0621C27.7394 19.2073 28 19.5815 28 20L28 27C28 27.5523 27.5523 28 27 28C26.4477 28 26 27.5523 26 27L26 22.7033L24.7593 24.1508C24.5693 24.3724 24.2919 24.5 24 24.5C23.7081 24.5 23.4307 24.3724 23.2407 24.1508L22 22.7033Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);