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="M27.7337 11.438C27.9057 10.9918 28 10.5069 28 10C28 7.79086 26.2091 6 24 6C21.7909 6 20 7.79086 20 10C20 10.5069 20.0943 10.9917 20.2663 11.438L12.5704 16.935C11.8752 16.3515 10.9786 16 10 16C7.79086 16 6 17.7909 6 20C6 22.1636 7.7178 23.926 9.86395 23.9977L12.1834 34.4353C10.8874 35.0971 10 36.4449 10 38C10 40.2091 11.7909 42 14 42C15.8639 42 17.43 40.7252 17.874 38.9999H30.126C30.57 40.7252 32.1361 42 34 42C36.2091 42 38 40.2091 38 38C38 36.4449 37.1126 35.0971 35.8165 34.4353L38.1359 23.9977C40.2821 23.9261 42 22.1636 42 20C42 17.7909 40.2091 16 38 16C37.0213 16 36.1248 16.3515 35.4296 16.9351L27.7337 11.438ZM24 12C25.1046 12 26 11.1046 26 10C26 8.89543 25.1046 8 24 8C22.8954 8 22 8.89543 22 10C22 11.1046 22.8954 12 24 12ZM26.5704 13.0649C25.8753 13.6485 24.9787 14 24 14C23.0213 14 22.1247 13.6485 21.4295 13.0649L13.7337 18.5619C13.9057 19.0082 14 19.4931 14 20C14 21.5551 13.1126 22.9029 11.8165 23.5647L14.136 34.0023C15.9396 34.0625 17.4407 35.3169 17.874 36.9999H30.126C30.5592 35.3169 32.0603 34.0626 33.8639 34.0023L36.1834 23.5647C34.8874 22.9029 34 21.5551 34 20C34 19.4931 34.0943 19.0082 34.2663 18.5619L26.5704 13.0649ZM12 20C12 21.1046 11.1046 22 10 22C8.89543 22 8 21.1046 8 20C8 18.8954 8.89543 18 10 18C11.1046 18 12 18.8954 12 20ZM16 38C16 39.1046 15.1046 40 14 40C12.8954 40 12 39.1046 12 38C12 36.8954 12.8954 36 14 36C15.1046 36 16 36.8954 16 38ZM38 22C39.1046 22 40 21.1046 40 20C40 18.8954 39.1046 18 38 18C36.8954 18 36 18.8954 36 20C36 21.1046 36.8954 22 38 22ZM36 38C36 39.1046 35.1046 40 34 40C32.8954 40 32 39.1046 32 38C32 36.8954 32.8954 36 34 36C35.1046 36 36 36.8954 36 38Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);