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="M26.9238 4C27.8914 4 28.7899 4.21665 29.5913 4.67461C30.276 5.06587 31.0533 5.60468 31.628 6.40924L31.6156 6.41809L31.6269 6.43321L33.9584 9.45552L33.9666 9.46632L34.7795 10.5502C35.7583 11.8429 36.3585 13.3317 36.5801 14.8649C35.9207 14.5328 35.1895 14.3234 34.4171 14.266C34.1749 13.3754 33.7638 12.5215 33.1838 11.7559L33.1809 11.752L32.709 11.1228C32.535 12.0671 32.1353 12.9766 31.5098 13.7607L25.4438 21.5961L28.9964 26.0871L31.234 23.1985V26C31.234 26.1437 31.245 26.2849 31.2663 26.4227L30.2702 27.7084L37.2191 36.6521C37.8623 37.4799 37.7572 38.6639 36.9781 39.3654L32.9122 43.0268C32.0516 43.8018 30.7148 43.6861 30.0001 42.7749L24.2094 35.3917L18.3652 42.843C17.6916 43.7019 16.4538 43.862 15.5838 43.2029L11.2054 39.8859C10.3155 39.2118 10.1498 37.9398 10.8372 37.0602L18.1511 27.7016L13.6469 21.9878L13.641 21.98C11.109 18.6379 11.1085 13.9837 13.6394 10.641L13.641 10.639L14.4523 9.55709L16.7887 6.52844C16.8241 6.48089 16.8604 6.43373 16.8975 6.38697C18.0073 4.84975 19.8517 4 21.6762 4H26.9238ZM24.1743 19.9687L28.7743 14.0271C28.1756 13.7019 27.496 13.5093 26.8334 13.5093H21.5857C20.8665 13.5093 20.1664 13.6876 19.574 14.0266L24.1743 19.9687ZM30.0098 12.4317C31.0686 11.0297 31.076 9.05029 30.0321 7.64018L29.932 7.51046L29.9466 7.49896C29.6182 7.07086 29.1501 6.726 28.5991 6.4111C28.1338 6.14525 27.5847 6 26.9238 6H21.6762C20.4332 6 19.2104 6.58966 18.5089 7.57171L18.4982 7.5867L18.3832 7.73584C17.8658 8.43472 17.6095 9.25167 17.6095 10.0667C17.6095 10.8772 17.8617 11.7462 18.3446 12.4333C19.3185 11.8099 20.4634 11.5093 21.5857 11.5093H26.8334C27.965 11.5093 29.0758 11.862 30.0098 12.4317ZM19.4258 29.3185L12.4131 38.2918L16.7915 41.6087L22.9373 33.7729L19.4258 29.3185ZM16.9091 13.8515C16.2873 13.0717 15.8932 12.14 15.717 11.2043L15.2381 11.8429L15.2352 11.8467C13.2457 14.4728 13.2438 18.1368 15.2295 20.7648L24.9963 33.1543L31.5738 41.5406L35.6398 37.8792L28.2204 28.3299L23.4252 22.2681L16.9091 13.8515Z" fill="black"/>
<path d="M34 18.0001C35.111 18.0086 36 18.9057 36 20C36 21.0995 35.1024 22 33.984 22C33.4317 22 32.984 22.4477 32.984 23V26C32.984 26.5523 33.4317 27 33.984 27C34.5363 27 34.984 26.5523 34.984 26V23.8749C36.7154 23.4327 38 21.8689 38 20C38 17.8072 36.2316 16.0345 34.048 16.0005L34.0286 16.0001L34.0161 16H33.984C33.9733 16 33.9627 16.0002 33.9521 16.0005C31.7685 16.0345 30 17.8072 30 20C30 20.5523 30.4478 21 31 21C31.5523 21 32 20.5523 32 20C32 18.9057 32.889 18.0086 34 18.0001Z" fill="black"/>
<path d="M35 29C35 29.5523 34.5523 30 34 30C33.4477 30 33 29.5523 33 29C33 28.4477 33.4477 28 34 28C34.5523 28 35 28.4477 35 29Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);