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 14.0001C26.222 14.0173 28 15.8114 28 18C28 20.1991 26.2048 22 23.9679 22C22.8633 22 21.9679 22.8954 21.9679 24V30C21.9679 31.1046 22.8633 32 23.9679 32C25.0725 32 25.9679 31.1046 25.9679 30V25.7498C29.4308 24.8653 32 21.7378 32 18C32 13.6144 28.4631 10.069 24.0959 10.001C24.0747 10.0003 24.0535 10 24.0321 10H23.9679C23.9466 10 23.9253 10.0003 23.9042 10.001C19.5369 10.069 16 13.6144 16 18C16 19.1046 16.8955 20 18 20C19.1046 20 20 19.1046 20 18C20 15.8114 21.778 14.0173 24 14.0001Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 38C25.1046 38 26 37.1046 26 36C26 34.8954 25.1046 34 24 34C22.8954 34 22 34.8954 22 36C22 37.1046 22.8954 38 24 38Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);