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="M13 12C13 10.3431 14.3431 9 16 9H32C33.173 9 34.2383 9.68361 34.7271 10.7499C35.2159 11.8161 35.0384 13.0695 34.2728 13.9581C32.5651 15.9403 30.0022 19.559 27.7147 23.7597C25.4117 27.9889 23.5344 32.5428 22.9688 36.4318C22.7303 38.0714 21.2078 39.2072 19.5682 38.9688C17.9286 38.7303 16.7928 37.2078 17.0312 35.5682C17.7455 30.6573 20.0016 25.3779 22.4453 20.8903C23.6008 18.7683 24.8292 16.7674 26.0153 15H16C14.3431 15 13 13.6569 13 12ZM16 11C15.4477 11 15 11.4477 15 12C15 12.5523 15.4477 13 16 13H27.9223C28.2968 13 28.6398 13.2092 28.8113 13.542C28.9828 13.8749 28.9539 14.2756 28.7366 14.5805C27.2747 16.6311 25.677 19.1377 24.2018 21.8468C21.805 26.2481 19.6752 31.2857 19.0104 35.8561C18.9309 36.4026 19.3095 36.9101 19.8561 36.9896C20.4026 37.0691 20.9101 36.6905 20.9896 36.1439C21.6048 31.9142 23.6084 27.1184 25.9582 22.8032C28.303 18.4974 30.9439 14.7579 32.7576 12.6527C33.0128 12.3565 33.072 11.9387 32.909 11.5833C32.7461 11.2279 32.391 11 32 11H16Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);