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 d="M7.54777 3.75L5.94168 8.76905C4.32067 13.8347 3.78111 19.1842 4.35791 24.4715L6.50609 44.1632L8.4943 43.9463L6.34611 24.2546C5.79967 19.2456 6.31083 14.1776 7.84652 9.3786L9.45262 4.35955L7.54777 3.75Z" fill="black"/>
<path d="M40.4522 3.75L42.0583 8.76905C43.6793 13.8347 44.2189 19.1842 43.6421 24.4715L41.4939 44.1632L39.5057 43.9463L41.6539 24.2546C42.2003 19.2456 41.6892 14.1776 40.1535 9.3786L38.5474 4.35955L40.4522 3.75Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 24.0548C13 29.0899 16.383 33.3349 21 34.6407V44.0548H23V35.01C23.3294 35.0396 23.6629 35.0548 24 35.0548C24.3371 35.0548 24.6706 35.0396 25 35.01V44.0548H27V34.6407C31.617 33.3349 35 29.0899 35 24.0548C35 17.9797 30.0751 13.0548 24 13.0548C17.9249 13.0548 13 17.9797 13 24.0548ZM16.511 26.508C16.5778 25.9598 17.0763 25.5695 17.6246 25.6363L18.4189 25.733C18.8376 25.784 19.152 25.359 18.9807 24.9736L18.907 24.808C18.2262 23.276 19.2744 21.5333 20.9467 21.4167C21.0661 21.4084 21.208 21.3441 21.3464 21.1546C21.4902 20.9576 21.5832 20.6795 21.5849 20.4051C21.5886 19.7933 21.7038 19.0495 22.1394 18.3954C22.5982 17.7065 23.3335 17.2355 24.3356 17.0684C24.8804 16.9777 25.3956 17.3457 25.4864 17.8904C25.5772 18.4352 25.2091 18.9504 24.6644 19.0412C24.1386 19.1289 23.9194 19.3309 23.8041 19.504C23.6656 19.7119 23.5873 20.0189 23.5849 20.4171C23.5808 21.0931 23.3636 21.7835 22.9616 22.3341C22.5541 22.8921 21.9145 23.3541 21.0858 23.4119C20.7979 23.432 20.6175 23.732 20.7347 23.9957L20.8083 24.1614C21.6106 25.9666 20.1381 27.9572 18.1771 27.7184L17.3827 27.6216C16.8345 27.5548 16.4442 27.0562 16.511 26.508ZM30.7419 19.6283C30.9335 20.1463 30.6688 20.7215 30.1508 20.913L28.4721 21.5338C28.1475 21.6537 28.0747 22.0801 28.3409 22.3011C30.0258 23.6994 29.1696 26.4371 26.9882 26.6262L25.5556 26.7503C25.1454 26.7859 24.9805 27.2977 25.2928 27.5661C26.7301 28.8013 26.294 31.1288 24.507 31.7598L23.8329 31.9978C23.3122 32.1817 22.7409 31.9086 22.557 31.3878C22.3731 30.867 22.6462 30.2958 23.167 30.1119L23.841 29.8739C24.1781 29.7549 24.2603 29.3159 23.9893 29.0829C22.3336 27.6602 23.2081 24.9463 25.3829 24.7578L26.8155 24.6336C27.2157 24.5989 27.3728 24.0967 27.0637 23.8401C25.6125 22.6357 26.0096 20.3119 27.7785 19.6579L29.4572 19.0372C29.9752 18.8456 30.5504 19.1103 30.7419 19.6283Z" fill="black"/>
<path d="M25.1499 6.05481C25.1499 5.50252 24.7022 5.05481 24.1499 5.05481C23.5976 5.05481 23.1499 5.50252 23.1499 6.05481V7.05481C23.1499 7.60709 23.5976 8.05481 24.1499 8.05481C24.7022 8.05481 25.1499 7.60709 25.1499 7.05481V6.05481Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);