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" stroke-width="1.5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.25 4C3.25 3.58579 3.58579 3.25 4 3.25H8C8.30335 3.25 8.57682 3.43273 8.69291 3.71299C8.809 3.99324 8.74483 4.31583 8.53033 4.53033L7.06066 6L12.5303 11.4697C12.8232 11.7626 12.8232 12.2374 12.5303 12.5303C12.2374 12.8232 11.7626 12.8232 11.4697 12.5303L6 7.06066L4.53033 8.53033C4.31583 8.74483 3.99324 8.809 3.71299 8.69291C3.43273 8.57682 3.25 8.30335 3.25 8V4Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.25 20C3.25 20.4142 3.58579 20.75 4 20.75H8C8.30335 20.75 8.57682 20.5673 8.69291 20.287C8.809 20.0068 8.74483 19.6842 8.53033 19.4697L7.06066 18L12.5303 12.5303C12.8232 12.2374 12.8232 11.7626 12.5303 11.4697C12.2374 11.1768 11.7626 11.1768 11.4697 11.4697L6 16.9393L4.53033 15.4697C4.31583 15.2552 3.99324 15.191 3.71299 15.3071C3.43273 15.4232 3.25 15.6967 3.25 16V20Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.75 4C20.75 3.58579 20.4142 3.25 20 3.25H16C15.6967 3.25 15.4232 3.43273 15.3071 3.71299C15.191 3.99324 15.2552 4.31583 15.4697 4.53033L16.9393 6L11.4697 11.4697C11.1768 11.7626 11.1768 12.2374 11.4697 12.5303C11.7626 12.8232 12.2374 12.8232 12.5303 12.5303L18 7.06066L19.4697 8.53033C19.6842 8.74483 20.0068 8.809 20.287 8.69291C20.5673 8.57682 20.75 8.30335 20.75 8V4Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.75 20C20.75 20.4142 20.4142 20.75 20 20.75H16C15.6967 20.75 15.4232 20.5673 15.3071 20.287C15.191 20.0068 15.2552 19.6842 15.4697 19.4697L16.9393 18L11.4697 12.5303C11.1768 12.2374 11.1768 11.7626 11.4697 11.4697C11.7626 11.1768 12.2374 11.1768 12.5303 11.4697L18 16.9393L19.4697 15.4697C19.6842 15.2552 20.0068 15.191 20.287 15.3071C20.5673 15.4232 20.75 15.6967 20.75 16V20Z" fill="currentColor"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);