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="M29.0324 15.0927C28.1785 14.6817 27.1806 14.3314 26 14C27.1806 13.6686 28.1785 13.3183 29.0324 12.9073C30.8541 12.0305 32.0204 10.8775 32.9069 9.0427C33.3192 8.18948 33.6709 7.18884 34 6C34.3291 7.18884 34.6808 8.18948 35.0931 9.0427C35.9796 10.8775 37.1459 12.0305 38.9676 12.9073C39.8215 13.3183 40.8194 13.6686 42 14C40.8194 14.3314 39.8215 14.6817 38.9676 15.0927C37.1459 15.9695 35.9796 17.1225 35.0931 18.9573C34.6808 19.8105 34.3291 20.8112 34 22C33.6709 20.8112 33.3192 19.8105 32.9069 18.9573C32.0204 17.1225 30.8541 15.9695 29.0324 15.0927ZM32.7224 15.2394C32.2485 14.769 31.7324 14.3606 31.1735 14C31.7324 13.6394 32.2485 13.231 32.7224 12.7606C33.2076 12.279 33.6286 11.7522 34 11.1786C34.3714 11.7522 34.7924 12.279 35.2776 12.7606C35.7515 13.231 36.2676 13.6394 36.8265 14C36.2676 14.3606 35.7515 14.769 35.2776 15.2394C34.7924 15.721 34.3714 16.2478 34 16.8214C33.6286 16.2478 33.2076 15.721 32.7224 15.2394Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.30387 29.0636C8.30249 28.6881 7.20569 28.3384 6 28C7.20569 27.6616 8.30249 27.3119 9.30387 26.9364C14.3869 25.0303 17.0111 22.4594 18.9365 17.3242C19.3134 16.3191 19.6635 15.2158 20 14C20.3365 15.2158 20.6866 16.3191 21.0635 17.3242C22.9889 22.4594 25.6131 25.0303 30.6961 26.9364C31.6975 27.3119 32.7943 27.6616 34 28C32.7943 28.3384 31.6975 28.6881 30.6961 29.0636C25.6131 30.9697 22.9889 33.5406 21.0635 38.6758C20.6866 39.6809 20.3365 40.7842 20 42C19.6635 40.7842 19.3134 39.6809 18.9365 38.6758C17.0111 33.5406 14.3869 30.9697 9.30387 29.0636ZM16.7074 31.2335C15.3644 29.9004 13.7907 28.8642 11.9422 28C13.7907 27.1358 15.3644 26.0996 16.7074 24.7665C18.0621 23.4217 19.1194 21.8372 20 19.9594C20.8806 21.8372 21.9379 23.4217 23.2926 24.7665C24.6356 26.0996 26.2093 27.1358 28.0578 28C26.2093 28.8642 24.6356 29.9004 23.2926 31.2335C21.9379 32.5783 20.8806 34.1628 20 36.0406C19.1194 34.1628 18.0621 32.5783 16.7074 31.2335Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);