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 d="M37.5 16.8449C37.5 12.8705 35.9682 9.75541 33.4947 7.64469C31.0848 5.58823 27.9616 4.63223 24.923 4.51312C19.1007 4.28488 12.0377 7.23751 10.5604 13.8405C10.2589 15.1879 11.1068 16.5246 12.4542 16.8261C13.8016 17.1275 15.1383 16.2796 15.4397 14.9322C16.1624 11.7019 20.0994 9.32786 24.7271 9.50928C26.9135 9.59499 28.8778 10.2779 30.2491 11.4481C31.5569 12.5641 32.5 14.2635 32.5 16.8449C32.5 19.394 31.228 21.0713 29.3719 22.2558C27.4261 23.4975 24.9842 24.0682 23.3259 24.184C22.0159 24.2755 21.0001 25.3648 21.0001 26.678V31C21.0001 32.3807 22.1193 33.5 23.5001 33.5C24.8808 33.5 26.0001 32.3807 26.0001 31V28.8489C27.9106 28.4606 30.1018 27.7213 32.0616 26.4707C34.9776 24.6099 37.5 21.5072 37.5 16.8449Z" fill="black"/>
<path d="M24 36C21.7909 36 20 37.7909 20 40C20 42.2091 21.7909 44 24 44C26.2092 44 28 42.2091 28 40C28 37.7909 26.2092 36 24 36Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.0001 28.8489C24.0001 27.8978 24.6698 27.0783 25.6018 26.8889C27.3366 26.5364 29.2825 25.8716 30.9857 24.7848C33.4812 23.1923 35.5 20.6587 35.5 16.8449C35.5 13.4272 34.2034 10.8786 32.1965 9.16606C30.2025 7.46449 27.5431 6.61736 24.8446 6.51158C22.271 6.41069 19.4279 7.01999 17.1068 8.3503C14.8123 9.66542 13.1043 11.6303 12.5121 14.2772C12.4518 14.5467 12.6214 14.814 12.8909 14.8743C13.1604 14.9346 13.4277 14.765 13.488 14.4955C14.5077 9.93772 19.6698 7.30949 24.8055 7.51081C27.3339 7.60993 29.7613 8.40265 31.5474 9.92675C33.3208 11.4401 34.5 13.7055 34.5 16.8449C34.5 20.2334 32.7339 22.4829 30.4477 23.9418C28.1499 25.4082 25.3616 26.0467 23.4652 26.1792C23.2032 26.1975 23.0001 26.4153 23.0001 26.678V31C23.0001 31.2761 23.2239 31.5 23.5001 31.5C23.7762 31.5 24.0001 31.2761 24.0001 31V28.8489ZM24 38C22.8955 38 22 38.8954 22 40C22 41.1046 22.8955 42 24 42C25.1046 42 26 41.1046 26 40C26 38.8954 25.1046 38 24 38ZM33.4947 7.64469C35.9682 9.75541 37.5 12.8705 37.5 16.8449C37.5 21.5072 34.9776 24.6099 32.0616 26.4707C30.1018 27.7213 27.9106 28.4606 26.0001 28.8489V31C26.0001 32.3807 24.8808 33.5 23.5001 33.5C22.1193 33.5 21.0001 32.3807 21.0001 31V26.678C21.0001 25.3648 22.0159 24.2755 23.3259 24.184C24.9842 24.0682 27.4261 23.4975 29.3719 22.2558C31.228 21.0713 32.5 19.394 32.5 16.8449C32.5 14.2635 31.5569 12.5641 30.2491 11.4481C28.8778 10.2779 26.9135 9.59499 24.7271 9.50928C20.0994 9.32786 16.1624 11.7019 15.4397 14.9322C15.1383 16.2796 13.8016 17.1275 12.4542 16.8261C11.1068 16.5246 10.2589 15.1879 10.5604 13.8405C12.0377 7.23751 19.1007 4.28488 24.923 4.51312C27.9616 4.63223 31.0848 5.58823 33.4947 7.64469ZM20 40C20 37.7909 21.7909 36 24 36C26.2092 36 28 37.7909 28 40C28 42.2091 26.2092 44 24 44C21.7909 44 20 42.2091 20 40Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);