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="M16.0961 11.1052C14.624 9.63232 12.2364 9.6315 10.7632 11.1034L10.0591 11.8069C8.71987 11.4263 7.22155 11.7669 6.16703 12.8285C4.61099 14.3951 4.61099 16.9376 6.16703 18.5042L7 19.3428V30H4V32H6.05051C5.40223 32.6353 5 33.5207 5 34.5C5 36.433 6.567 38 8.5 38C10.433 38 12 36.433 12 34.5C12 33.5207 11.5978 32.6353 10.9495 32H37.0505C36.4022 32.6353 36 33.5207 36 34.5C36 36.433 37.567 38 39.5 38C41.433 38 43 36.433 43 34.5C43 33.5207 42.5978 32.6353 41.9495 32H44V30H40V26.8873C41.7218 26.4646 43 24.8993 43 23.033C43 20.8423 41.2388 19.0664 39.0662 19.0664H18.11C18.0285 19.0664 17.9502 19.0337 17.8925 18.9756L17.5261 18.6068L17.8945 18.2387C19.3678 16.7667 19.3686 14.3793 17.8963 12.9063L16.0961 11.1052ZM16.1167 17.1878L16.4809 16.8239C17.1727 16.1327 17.1731 15.0118 16.4818 14.3202L14.6816 12.5191C13.9902 11.8273 12.8687 11.8269 12.1768 12.5182L11.8263 12.8684L16.1167 17.1878ZM41 23.033C41 21.9311 40.1185 21.0664 39.0662 21.0664H18.11C17.4932 21.0664 16.905 20.8194 16.4736 20.3851L10.3677 14.238C9.59731 13.4623 8.35643 13.4623 7.586 14.238C6.80467 15.0246 6.80467 16.3081 7.586 17.0948L15.4379 24.9997H39.0662C40.1186 24.9997 41 24.1349 41 23.033ZM14.2752 26.6672C14.4867 26.8801 14.7733 26.9997 15.0722 26.9997H38V30H9V21.3563L14.2752 26.6672ZM10 34.5C10 35.3284 9.32843 36 8.5 36C7.67157 36 7 35.3284 7 34.5C7 33.6716 7.67157 33 8.5 33C9.32843 33 10 33.6716 10 34.5ZM39.5 36C40.3284 36 41 35.3284 41 34.5C41 33.6716 40.3284 33 39.5 33C38.6716 33 38 33.6716 38 34.5C38 35.3284 38.6716 36 39.5 36Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);