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="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_4044_8414)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.9546 0.893453C12.4274 0.366247 11.5726 0.366243 11.0454 0.893453L0.893941 11.0449C0.366735 11.5721 0.366731 12.4269 0.893941 12.9541L11.0454 23.1056C11.5726 23.6328 12.4274 23.6328 12.9546 23.1056L23.1061 12.9541C23.6333 12.4269 23.6333 11.5721 23.1061 11.0449L12.9546 0.893453ZM16.5303 11.5303C16.8232 11.2374 16.8232 10.7626 16.5303 10.4697L14.5303 8.46967C14.2374 8.17678 13.7626 8.17678 13.4697 8.46967C13.1768 8.76256 13.1768 9.23744 13.4697 9.53033L14.1893 10.25H10C9.25608 10.25 8.57493 10.6144 8.09467 11.0947C7.61441 11.5749 7.25 12.2561 7.25 13V14C7.25 14.4142 7.58579 14.75 8 14.75C8.41421 14.75 8.75 14.4142 8.75 14V13C8.75 12.7439 8.88559 12.4251 9.15533 12.1553C9.42507 11.8856 9.74392 11.75 10 11.75H14.1893L13.4697 12.4697C13.1768 12.7626 13.1768 13.2374 13.4697 13.5303C13.7626 13.8232 14.2374 13.8232 14.5303 13.5303L16.5303 11.5303Z" fill="currentColor"/>
</g>
<defs>
<clipPath id="clip0_4044_8414">
<rect width="24" height="24" fill="white"/>
</clipPath>
</defs>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);