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="M21 11V11.1707C20.6872 11.0602 20.3506 11 20 11C18.3431 11 17 12.3431 17 14V15.1707C16.6872 15.0602 16.3506 15 16 15C14.3431 15 13 16.3431 13 18V29.5252C13 35.3103 17.6897 40 23.4748 40C27.1123 40 30.4893 38.1129 32.3957 35.015L38.1312 25.6948C38.7819 24.6375 38.7156 23.2889 37.9644 22.3005C36.7747 20.7351 34.4273 20.7145 33.2103 22.2587L31 25.0631V14C31 12.3431 29.6569 11 28 11C27.6494 11 27.3128 11.0602 27 11.1707V11C27 9.34315 25.6569 8 24 8C22.3431 8 21 9.34315 21 11ZM25 11C25 10.4477 24.5523 10 24 10C23.4477 10 23 10.4477 23 11V23H21V14C21 13.4477 20.5523 13 20 13C19.4477 13 19 13.4477 19 14V25H17V18C17 17.4477 16.5523 17 16 17C15.4477 17 15 17.4477 15 18V29.5252C15 34.2057 18.7943 38 23.4748 38C26.4177 38 29.15 36.4732 30.6924 33.9668L36.4279 24.6466C36.6457 24.2928 36.6235 23.8415 36.3721 23.5107C35.9739 22.9868 35.1884 22.9799 34.7811 23.4967L32.5708 26.3011C31.396 27.7916 29 26.9609 29 25.0631V14C29 13.4477 28.5523 13 28 13C27.4477 13 27 13.4477 27 14V23H25V11Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 4C35.0457 4 44 12.9543 44 24C44 35.0457 35.0457 44 24 44C12.9543 44 4 35.0457 4 24C4 12.9543 12.9543 4 24 4ZM42 24C42 14.0589 33.9411 6 24 6C14.0589 6 6 14.0589 6 24C6 33.9411 14.0589 42 24 42C33.9411 42 42 33.9411 42 24Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);