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="M28 10C28 10.5069 27.9057 10.9917 27.7337 11.438L35.4296 16.9351C36.1248 16.3515 37.0213 16 38 16C40.2091 16 42 17.7909 42 20C42 22.1636 40.2822 23.926 38.136 23.9977L35.8165 34.4353C37.1126 35.0971 38 36.4449 38 38C38 40.2091 36.2091 42 34 42C32.1361 42 30.57 40.7252 30.126 38.9999H17.874C17.43 40.7252 15.8639 42 14 42C11.7909 42 10 40.2091 10 38C10 36.4449 10.8874 35.0971 12.1835 34.4353L9.864 23.9977C7.71782 23.926 6 22.1636 6 20C6 17.7909 7.79086 16 10 16C10.9787 16 11.8752 16.3515 12.5704 16.935L20.2663 11.438C20.0943 10.9917 20 10.5069 20 10C20 7.79086 21.7909 6 24 6C26.2091 6 28 7.79086 28 10ZM21.4295 13.0649L13.7337 18.5619C13.9057 19.0082 14 19.4931 14 20C14 21.5551 13.1126 22.9029 11.8166 23.5647L14.136 34.0023C15.9396 34.0625 17.4407 35.3169 17.874 36.9999H30.126C30.5593 35.3169 32.0603 34.0625 33.864 34.0023L36.1834 23.5647C34.8874 22.9029 34 21.5551 34 20C34 19.4931 34.0943 19.0082 34.2663 18.5619L26.5705 13.0649C25.8753 13.6485 24.9787 14 24 14C23.0213 14 22.1247 13.6485 21.4295 13.0649Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);