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="M9 24C9 15.7157 15.7157 9 24 9C32.2843 9 39 15.7157 39 24C39 27.0559 38.0852 29.9006 36.5147 32.2721L38.1213 33.8787C39.2929 35.0503 39.2929 36.9497 38.1213 38.1213C36.9497 39.2929 35.0503 39.2929 33.8787 38.1213L32.2721 36.5147C29.9006 38.0852 27.0559 39 24 39C15.7157 39 9 32.2843 9 24ZM24 11C16.8203 11 11 16.8203 11 24C11 31.1797 16.8203 37 24 37C26.9212 37 29.6148 36.0377 31.7849 34.4124L32.4786 33.8928L35.2929 36.7071C35.6834 37.0976 36.3166 37.0976 36.7071 36.7071C37.0976 36.3166 37.0976 35.6834 36.7071 35.2929L33.8928 32.4786L34.4124 31.7849C36.0377 29.6148 37 26.9212 37 24C37 16.8203 31.1797 11 24 11ZM24 15C19.0294 15 15 19.0294 15 24C15 28.9706 19.0294 33 24 33C25.3907 33 26.7061 32.6852 27.8804 32.1231L25.8787 30.1213C24.7071 28.9497 24.7071 27.0503 25.8787 25.8787C27.0503 24.7071 28.9497 24.7071 30.1213 25.8787L32.1231 27.8804C32.6852 26.7061 33 25.3907 33 24C33 19.0294 28.9706 15 24 15ZM13 24C13 17.9249 17.9249 13 24 13C30.0751 13 35 17.9249 35 24C35 26.2405 34.3291 28.3274 33.1769 30.067L32.5013 31.0871L28.7071 27.2929C28.3166 26.9024 27.6834 26.9024 27.2929 27.2929C26.9024 27.6834 26.9024 28.3166 27.2929 28.7071L31.0871 32.5013L30.067 33.1769C28.3274 34.3291 26.2405 35 24 35C17.9249 35 13 30.0751 13 24Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);