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="M24.8 33H27.5C34.4036 33 40 27.4036 40 20.5C40 13.5964 34.4036 8 27.5 8H20.5C13.5964 8 8 13.5964 8 20.5C8 28.5608 12.5962 33.3807 17.4302 36.2857C19.8562 37.7437 22.2996 38.6857 24.1465 39.2629C24.3744 39.3341 24.5926 39.3996 24.8 39.4597V33ZM26.8 42C26.8 42 26.0357 41.8714 24.8 41.5367C19.5898 40.1253 6 35.0495 6 20.5C6 12.4919 12.4919 6 20.5 6H27.5C35.5081 6 42 12.4919 42 20.5C42 28.5081 35.5081 35 27.5 35H26.8V42Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M27.6911 12.4815C28.7208 13.1664 29.4975 14.2754 29.4975 15.7612C29.4975 17.3398 28.8607 18.4998 27.8296 19.2103C27.4023 19.5048 26.9424 19.6971 26.4998 19.8236V21.356C26.4998 22.1844 25.8282 22.856 24.9998 22.856C24.1713 22.856 23.4998 22.1844 23.4998 21.356V18.5586C23.4998 17.7691 24.1118 17.1147 24.8996 17.062C25.4537 17.0249 25.874 16.9146 26.1273 16.74C26.234 16.6666 26.3105 16.5823 26.3679 16.4678C26.4275 16.3486 26.4975 16.1339 26.4975 15.7612C26.4975 15.4485 26.3745 15.2088 26.0296 14.9794C25.6376 14.7186 25.0076 14.5266 24.2511 14.5025C23.5026 14.4787 22.7758 14.625 22.2416 14.884C21.7046 15.1443 21.5084 15.4358 21.4531 15.6513C21.247 16.4537 20.4295 16.9371 19.6271 16.731C18.8247 16.5249 18.3413 15.7074 18.5474 14.905C18.8919 13.5637 19.8953 12.6875 20.9328 12.1845C21.9731 11.6802 23.1956 11.4674 24.3464 11.504C25.4893 11.5403 26.7087 11.8281 27.6911 12.4815Z" fill="black"/>
<path d="M27 27C27 28.1046 26.1046 29 25 29C23.8954 29 23 28.1046 23 27C23 25.8954 23.8954 25 25 25C26.1046 25 27 25.8954 27 27Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);