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="M31.6954 10.0795C32.7561 8.80669 34.6478 8.63472 35.9206 9.69541C37.1935 10.7561 37.3654 12.6478 36.3047 13.9206L27.9052 24.0001L36.3047 34.0795C37.3654 35.3524 37.1935 37.2441 35.9206 38.3047C34.6478 39.3654 32.7561 39.1935 31.6954 37.9206L24.0001 28.6862L16.3047 37.9206C15.244 39.1935 13.3524 39.3654 12.0795 38.3047C10.8067 37.2441 10.6347 35.3524 11.6954 34.0795L20.095 24.0001L11.6954 13.9206C10.6347 12.6478 10.8067 10.7561 12.0795 9.69541C13.3524 8.63472 15.244 8.80669 16.3047 10.0795L24.0001 19.3139L31.6954 10.0795ZM34.6403 11.2319C34.216 10.8783 33.5854 10.9356 33.2319 11.3599L32.4636 10.7197L33.2319 11.3599L24.7683 21.5162C24.5783 21.7442 24.2969 21.876 24.0001 21.876C23.7033 21.876 23.4218 21.7442 23.2319 21.5162L14.7683 11.3599C14.4147 10.9356 13.7842 10.8783 13.3599 11.2319C12.9356 11.5854 12.8783 12.216 13.2319 12.6403L22.1649 23.3599C22.4739 23.7307 22.4739 24.2694 22.1649 24.6403L13.2319 35.3599C12.8783 35.7842 12.9356 36.4147 13.3599 36.7683C13.7842 37.1219 14.4147 37.0645 14.7683 36.6403L23.2319 26.484C23.4218 26.256 23.7033 26.1242 24.0001 26.1242C24.2969 26.1242 24.5783 26.256 24.7683 26.484L33.2319 36.6403C33.5854 37.0645 34.216 37.1219 34.6403 36.7683C35.0645 36.4147 35.1219 35.7842 34.7683 35.3599L25.8353 24.6403C25.5262 24.2694 25.5262 23.7307 25.8353 23.3599L34.7683 12.6403C35.1219 12.216 35.0645 11.5854 34.6403 11.2319Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);