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="M19.7725 8.30157L21.2628 7.4536L22.2435 9.15216C23.5684 8.71843 25.0646 9.25298 25.7921 10.504L30.3148 18.2808C31.1477 19.7131 30.6576 21.5421 29.2202 22.366L28.3717 22.8524L29.0488 24.161L26.3749 25.5233L25.7658 24.346L25.0986 24.7284C23.6611 25.5523 21.8206 25.0592 20.9877 23.6269L18.0659 18.6028C15.503 20.0769 13.7356 21.7229 12.7876 23.6052C11.9897 25.1894 11.7274 27.0311 12.1688 29.2423C13.6009 28.4506 15.2478 28 17 28C20.2697 28 23.1729 29.5692 24.9975 31.9957L37.0836 25.1846L38.0764 26.9208L26.0342 33.707C26.6534 35.0078 27 36.4634 27 38C27 38.6849 26.9311 39.3538 26.8 40H40C40.5523 40 41 40.4477 41 41C41 41.5523 40.5523 42 40 42H7.83209C7.2969 40.7751 7 39.4222 7 38C7 35.0046 8.31701 32.3168 10.4036 30.484C9.64219 27.5566 9.85852 24.9748 11.0013 22.7056C12.1866 20.3521 14.3072 18.4589 17.0605 16.8739L16.465 15.85C15.825 14.7496 15.9661 13.4149 16.7178 12.4819L15.6565 10.6436L17.1648 9.78542L15.9236 7.55799L18.5536 6.11401L19.7725 8.30157ZM28.5796 19.2754L24.0569 11.4985C23.7793 11.0211 23.1658 10.8567 22.6866 11.1314L18.5651 13.4938C18.0859 13.7684 17.9226 14.3781 18.2002 14.8555L22.7229 22.6323C23.0005 23.1098 23.614 23.2742 24.0932 22.9995L28.2147 20.6371C28.6939 20.3625 28.8572 19.7528 28.5796 19.2754ZM24.7485 40C24.9125 39.362 25 38.6922 25 38C25 36.8203 24.7447 35.7003 24.2862 34.6921L19.4822 37.3994L18.4895 35.6632L23.236 32.9883C21.7697 31.1661 19.521 30 17 30C12.5817 30 9 33.5817 9 38C9 38.6922 9.08747 39.362 9.25153 40H24.7485Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);