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="M10 18C8.89543 18 8 18.8954 8 20V26C8 27.1046 8.89543 28 10 28H14V18H10ZM14 30H12V38C12 38.5523 12.4477 39 13 39C13.5523 39 14 38.5523 14 38V30ZM10 30C7.79086 30 6 28.2091 6 26V20C6 17.7909 7.79086 16 10 16H15C15.5523 16 16 16.4477 16 17V38C16 39.6569 14.6569 41 13 41C11.3431 41 10 39.6569 10 38V30Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.4812 7.12339C30.8012 7.29903 31 7.63502 31 8V18C33.2091 18 35 19.7909 35 22V23C35 25.2091 33.2091 27 31 27V37C31 37.365 30.8012 37.701 30.4812 37.8766C30.1613 38.0522 29.771 38.0396 29.4631 37.8437L18.4631 30.8437C18.1747 30.6601 18 30.3419 18 30V15C18 14.6581 18.1747 14.3399 18.4631 14.1563L29.4631 7.15634C29.771 6.96039 30.1613 6.94776 30.4812 7.12339ZM31 25C32.1046 25 33 24.1046 33 23V22C33 20.8954 32.1046 20 31 20V25ZM20 15.5489V29.4511L29 35.1783V9.82167L20 15.5489Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M40.8322 17.4453C41.1385 17.9048 41.0143 18.5257 40.5548 18.832L37.5548 20.8321C37.0953 21.1384 36.4744 21.0142 36.1681 20.5547C35.8617 20.0952 35.9859 19.4743 36.4454 19.1679L39.4454 17.1679C39.9049 16.8616 40.5258 16.9858 40.8322 17.4453ZM36.0001 24C36.0001 23.4477 36.4478 23 37.0001 23H41.0001C41.5524 23 42.0001 23.4477 42.0001 24C42.0001 24.5523 41.5524 25 41.0001 25H37.0001C36.4478 25 36.0001 24.5523 36.0001 24ZM36.1681 27.4453C36.4744 26.9858 37.0953 26.8616 37.5548 27.1679L40.5548 29.168C41.0143 29.4743 41.1385 30.0952 40.8322 30.5547C40.5258 31.0142 39.9049 31.1384 39.4454 30.8321L36.4454 28.8321C35.9859 28.5257 35.8617 27.9048 36.1681 27.4453Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);