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="M33.4907 16.3891C32.7543 17.2124 31.4899 17.2828 30.6667 16.5464C29.3361 15.3563 27.7083 14.5417 25.9509 14.1922C24.0111 13.8063 22.0004 14.0043 20.1732 14.7612C18.3459 15.5181 16.7841 16.7998 15.6853 18.4443C14.5865 20.0888 14 22.0222 14 24C14 25.9778 14.5865 27.9112 15.6853 29.5557C16.7841 31.2002 18.3459 32.4819 20.1732 33.2388C22.0004 33.9957 24.0111 34.1937 25.9509 33.8079C27.4247 33.5147 28.8074 32.8945 30 32V26H24C22.8954 26 22 25.1046 22 24C22 22.8954 22.8954 22 24 22L32 22C33.1046 22 34 22.8954 34 24V32.9443C34 33.5134 33.7575 34.0556 33.3333 34.435C31.4706 36.1011 29.1917 37.2416 26.7313 37.731C24.0155 38.2712 21.2006 37.9939 18.6424 36.9343C16.0843 35.8747 13.8978 34.0803 12.3594 31.778C10.8211 29.4757 10 26.7689 10 24C10 21.2311 10.8211 18.5243 12.3594 16.222C13.8978 13.9197 16.0843 12.1253 18.6424 11.0657C21.2006 10.0061 24.0155 9.72882 26.7313 10.269C29.1917 10.7584 31.4706 11.8989 33.3333 13.565C34.1566 14.3014 34.2271 15.5658 33.4907 16.3891Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);