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="M9.17647 8.5C7.42215 8.5 6 9.93908 6 11.7143V31C6 32.7752 7.42215 34.2143 9.17647 34.2143H19.7646V36.3572H15.5293V38.5H32.4705V36.3572H28.2353V34.2143H38.8235C40.5778 34.2143 42 32.7752 42 31V11.7143C42 9.93908 40.5778 8.5 38.8235 8.5H9.17647ZM21.8823 36.3572V34.2143H26.1177V36.3572H21.8823ZM13.4119 12.7858H15.5296V14.9286H17.6475V17.0715H15.5296V19.2143H13.4119V17.0715H11.2945L11.2945 14.9286H13.4119V12.7858ZM11.2939 23.5001C11.2939 22.9083 11.768 22.4286 12.3528 22.4286H16.5881C17.1728 22.4286 17.6469 22.9083 17.6469 23.5001V27.7858C17.6469 28.3775 17.1728 28.8572 16.5881 28.8572H12.3528C11.768 28.8572 11.2939 28.3775 11.2939 27.7858V23.5001ZM20.8234 13.8572C20.8234 13.2655 21.2974 12.7858 21.8822 12.7858H26.1175C26.7023 12.7858 27.1763 13.2655 27.1763 13.8572V18.1429C27.1763 18.7346 26.7023 19.2143 26.1175 19.2143H21.8822C21.2974 19.2143 20.8234 18.7346 20.8234 18.1429V13.8572ZM20.8232 23.5001C20.8232 22.9083 21.2973 22.4286 21.8821 22.4286H26.1174C26.7021 22.4286 27.1762 22.9083 27.1762 23.5001V27.7858C27.1762 28.3775 26.7021 28.8572 26.1174 28.8572H21.8821C21.2973 28.8572 20.8232 28.3775 20.8232 27.7858V23.5001ZM30.3527 13.8572C30.3527 13.2655 30.8268 12.7858 31.4116 12.7858H35.6469C36.2316 12.7858 36.7057 13.2655 36.7057 13.8572V18.1429C36.7057 18.7346 36.2316 19.2143 35.6469 19.2143H31.4116C30.8268 19.2143 30.3527 18.7346 30.3527 18.1429V13.8572Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);