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="M28.5 8.5C28.5 10.9853 26.4853 13 24 13C21.5147 13 19.5 10.9853 19.5 8.5C19.5 6.01472 21.5147 4 24 4C26.4853 4 28.5 6.01472 28.5 8.5ZM26.5 8.5C26.5 9.88071 25.3807 11 24 11C22.6193 11 21.5 9.88071 21.5 8.5C21.5 7.11929 22.6193 6 24 6C25.3807 6 26.5 7.11929 26.5 8.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.9772 15C18.8169 15 17.6644 15.2625 16.6248 15.8916C15.5882 16.5189 14.842 17.4029 14.322 18.3698C13.3372 20.2008 13.062 22.5156 13.062 24.8261V24.9142C13.062 24.9435 13.0633 24.9729 13.0659 25.0021L13.0736 25.0899C13.0802 25.1648 13.0851 25.4168 13.079 26.0102C13.0777 26.1389 13.076 26.2775 13.0742 26.4259L13.0741 26.4278C13.0686 26.8802 13.062 27.4183 13.062 28C13.062 29.6569 14.4052 31 16.062 31C16.3897 31 16.7049 30.9475 16.9999 30.8505V31L17 31.0111L17 41C17 42.604 18.2617 43.9242 19.8641 43.9969C21.4664 44.0696 22.8425 42.869 22.9877 41.2716L23.8306 32H24.1695L25.0123 41.2716C25.1576 42.869 26.5336 44.0696 28.136 43.9969C29.7383 43.9242 31 42.604 31 41V30.8294C31.3127 30.9399 31.6492 31 31.9998 31C33.6566 31 34.9998 29.6569 34.9998 28C34.9998 27.4193 34.9932 26.882 34.9877 26.4301L34.9876 26.4259C34.9858 26.2775 34.9841 26.1389 34.9828 26.0102C34.9766 25.4168 34.9815 25.1648 34.9881 25.0899L34.9959 25.0021C34.9985 24.9729 34.9998 24.9435 34.9998 24.9142V24.8261C34.9997 22.5156 34.7245 20.2008 33.7398 18.3698C33.2198 17.4029 32.4736 16.5189 31.437 15.8916C30.3974 15.2625 29.2449 15 28.0845 15H19.9772ZM16.062 29C16.4908 29 16.8586 28.7293 17 28.3483V21.5H19V30.9974L19 31L19 41C19 41.5347 19.4206 41.9747 19.9547 41.999C20.4888 42.0232 20.9475 41.623 20.9959 41.0905L21.9215 30.9095C21.9683 30.3944 22.4002 30 22.9174 30H25.0827C25.5999 30 26.0317 30.3944 26.0786 30.9095L27.0041 41.0905C27.0525 41.623 27.5112 42.0232 28.0453 41.999C28.5794 41.9747 29 41.5347 29 41L29 29.9969L28.9999 29.9854L28.9999 29.9807V28.0263L29 28.014V21.5H31V28.0225C31.0118 28.5643 31.455 29 31.9998 29C32.552 29 32.9998 28.5523 32.9998 28C32.9998 27.4314 32.9933 26.9041 32.9878 26.4505L32.9876 26.4383C32.9874 26.4203 32.9872 26.4025 32.987 26.3848C32.9854 26.2608 32.984 26.1423 32.9829 26.0309C32.9771 25.4742 32.9787 25.1092 32.9959 24.914L32.9998 24.8701V24.8261C32.9997 22.6145 32.7248 20.7049 31.9784 19.3171C31.5959 18.6059 31.0794 18.0129 30.4015 17.6027C29.7226 17.1918 28.9408 17 28.0845 17H19.9772C19.1209 17 18.3392 17.1918 17.6603 17.6027C16.9824 18.0129 16.4659 18.6059 16.0834 19.3171C15.337 20.7049 15.062 22.6145 15.062 24.8261V24.8701L15.0659 24.914C15.0831 25.1092 15.0847 25.4742 15.0789 26.0309C15.0775 26.1616 15.0758 26.302 15.074 26.4497C15.0685 26.9033 15.062 27.4314 15.062 28C15.062 28.5523 15.5097 29 16.062 29Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);