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="M27.6121 5.53462C25.6433 3.48846 22.3567 3.48846 20.3879 5.53462L19.8602 6.0831H15C12.2448 6.0831 10 8.30376 10 11.0569V33.0262C10 35.7793 12.2448 38 15 38H18V40H23V44H25V40H30V38H33C35.7552 38 38 35.7794 38 33.0262V23H36V27.5388C35.7222 27.3234 35.4135 27.1103 35.0748 26.9132C33.2501 25.8513 30.6105 25.2987 27.4919 27.1387C24.924 28.6537 22.5089 29.0636 19.8818 29.1195C18.7111 29.1444 17.5143 29.0991 16.231 29.0505C16.056 29.0438 15.8789 29.0371 15.7005 29.0306C14.5326 28.9875 13.3017 28.9498 12 28.9709V11.0569C12 9.4207 13.3369 8.0831 15 8.0831H20.2857C20.5576 8.0831 20.8178 7.97238 21.0063 7.77645L21.8291 6.92133C23.0111 5.69289 24.9889 5.69289 26.1709 6.92133L26.9937 7.77645C27.1822 7.97238 27.4424 8.0831 27.7143 8.0831H33.3302C34.8109 8.0831 36 9.27385 36 10.7289V15H38V10.7289C38 8.1569 35.903 6.0831 33.3302 6.0831H28.1398L27.6121 5.53462ZM15.6267 31.0292C14.4539 30.9859 13.2549 30.9498 12 30.9712V33.0262C12 34.6624 13.3369 36 15 36H33C34.6631 36 36 34.6624 36 33.0262V30.3295C35.9122 30.2186 35.7913 30.0741 35.6392 29.9108C35.2727 29.5177 34.7407 29.0328 34.0689 28.6418C32.7749 27.8888 30.9145 27.4415 28.5081 28.8612C25.551 30.6059 22.766 31.0586 19.9243 31.119C18.6899 31.1453 17.4295 31.0974 16.1531 31.049C15.9779 31.0423 15.8025 31.0357 15.6267 31.0292Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.5 14C18.8973 14 19.2569 14.2351 19.4162 14.5991L22.0324 20.5791C22.0387 20.5926 22.0447 20.6063 22.0504 20.6201L22.9162 22.5991C23.1375 23.1051 22.9068 23.6947 22.4008 23.9161C21.8948 24.1375 21.3052 23.9067 21.0838 23.4008L20.471 22H16.529L15.9162 23.4008C15.6948 23.9067 15.1052 24.1375 14.5992 23.9161C14.0932 23.6947 13.8625 23.1051 14.0838 22.5991L14.9496 20.6201C14.9504 20.6184 14.9511 20.6167 14.9518 20.615C14.9568 20.6029 14.9621 20.5909 14.9676 20.5791L17.5838 14.5991C17.7431 14.2351 18.1027 14 18.5 14ZM19.596 20L18.5 17.4948L17.404 20H19.596Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M25 14C24.4477 14 24 14.4477 24 15V23C24 23.2652 24.1054 23.5195 24.2929 23.7071C24.4804 23.8946 24.7348 24 25 24H28.125C29.7726 24 31 22.595 31 21C31 20.2488 30.7278 19.5399 30.2678 19C30.7278 18.46 31 17.7511 31 17C31 15.4049 29.7726 14 28.125 14H25ZM29 17C29 17.614 28.5484 18 28.125 18H26V16H28.125C28.5484 16 29 16.3859 29 17ZM29 21C29 20.3859 28.5484 20 28.125 20H26V22H28.125C28.5484 22 29 21.614 29 21Z" fill="black"/>
<path d="M32 19C32 18.4477 32.4477 18 33 18H34V17C34 16.4477 34.4477 16 35 16C35.5523 16 36 16.4477 36 17V18H37C37.5523 18 38 18.4477 38 19C38 19.5522 37.5523 20 37 20H36V21C36 21.5522 35.5523 22 35 22C34.4477 22 34 21.5522 34 21V20H33C32.4477 20 32 19.5522 32 19Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);