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.0531 7.67922C30.2556 7.1985 31.5433 6.96855 32.8375 7.00345C34.1317 7.03836 35.4052 7.3374 36.5802 7.88223C37.7549 8.42691 38.8064 9.20579 39.6708 10.1712C42.1651 12.9499 42.5677 16.8147 41.2977 20.0818C39.757 24.0453 36.8099 27.6737 33.7094 31.033C32.6129 32.2211 31.5045 33.3689 30.4217 34.4902C28.3868 36.5974 26.4421 38.6113 24.8356 40.6239C24.6588 40.8453 24.3964 40.9814 24.1135 40.9982C23.8307 41.0151 23.5539 40.9111 23.3521 40.7122C22.9776 40.343 22.5893 39.9621 22.1902 39.5705C19.705 37.1324 16.7958 34.2783 14.1253 31.2437C11.0331 27.7298 8.1897 23.8969 6.6766 20.0887C6.19769 18.8834 5.96867 17.593 6.00344 16.2961C6.03821 14.9992 6.33604 13.7229 6.87886 12.5451C7.42159 11.3675 8.19787 10.313 9.16054 9.44584C13.0399 5.94248 19.0168 6.5412 22.6059 10.1413L24.0541 11.5939L25.8434 9.79909C26.7585 8.88129 27.8505 8.15993 29.0531 7.67922ZM32.7836 9.00273C31.7618 8.97517 30.7451 9.1567 29.7955 9.53633C28.8458 9.91596 27.983 10.4858 27.2598 11.2112L24.7623 13.7163C24.5746 13.9045 24.3198 14.0102 24.0541 14.0102C23.7883 14.0102 23.5335 13.9045 23.3459 13.7163L21.1896 11.5533C18.249 8.60384 13.4837 8.23614 10.5006 10.9305L10.4995 10.9315C9.73854 11.6168 9.12458 12.4507 8.69524 13.3823C8.2659 14.3138 8.03023 15.3235 8.00272 16.3497C7.97521 17.3758 8.15644 18.3968 8.53526 19.3502C9.91955 22.8342 12.5796 26.4598 15.6267 29.9224C18.2446 32.8972 21.0957 35.6946 23.5835 38.1356C23.7151 38.2647 23.8456 38.3928 23.9751 38.5199C25.4984 36.7098 27.2819 34.8619 29.0782 33.0008C30.1448 31.8956 31.2159 30.7858 32.2397 29.6766C35.3173 26.342 38.0383 22.9465 39.4336 19.3572C40.4696 16.6918 40.1046 13.6483 38.1823 11.507L38.1813 11.5059C37.4979 10.7425 36.6669 10.127 35.7389 9.69666C34.8109 9.26637 33.8053 9.03029 32.7836 9.00273Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M26.909 14.5359L18.9687 24.8016C18.7145 25.1302 18.9488 25.6075 19.3642 25.6075H23.8908L22.3635 33.3577L30.3038 23.092C30.558 22.7634 30.3237 22.2861 29.9083 22.2861H25.3817L26.909 14.5359Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);