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="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3 9.25C2.58579 9.25 2.25 9.58579 2.25 10V19C2.25 20.5188 3.48122 21.75 5 21.75H11.5V18.2502C11.5 14.5223 14.5221 11.5002 18.25 11.5002C19.5314 11.5002 20.7294 11.9728 21.75 12.5932V10C21.75 9.58579 21.4142 9.25 21 9.25H3Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 1.25C7.41421 1.25 7.75 1.58579 7.75 2V6C7.75 6.41421 7.41421 6.75 7 6.75C6.58579 6.75 6.25 6.41421 6.25 6V4.75H5C4.30964 4.75 3.75 5.30964 3.75 6V10C3.75 10.4142 3.41421 10.75 3 10.75C2.58579 10.75 2.25 10.4142 2.25 10V6C2.25 4.48122 3.48122 3.25 5 3.25H6.25V2C6.25 1.58579 6.58579 1.25 7 1.25ZM15 1.25C15.4142 1.25 15.75 1.58579 15.75 2V6C15.75 6.41421 15.4142 6.75 15 6.75C14.5858 6.75 14.25 6.41421 14.25 6V4.75H10.5C10.0858 4.75 9.75 4.41421 9.75 4C9.75 3.58579 10.0858 3.25 10.5 3.25H14.25V2C14.25 1.58579 14.5858 1.25 15 1.25ZM17.75 4C17.75 3.58579 18.0858 3.25 18.5 3.25H19C20.5188 3.25 21.75 4.48122 21.75 6V10C21.75 10.4142 21.4142 10.75 21 10.75C20.5858 10.75 20.25 10.4142 20.25 10V6C20.25 5.30964 19.6904 4.75 19 4.75H18.5C18.0858 4.75 17.75 4.41421 17.75 4Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.9906 14.75C16.6121 14.75 15.3733 15.7387 14.9136 17.222C14.791 17.6177 14.3709 17.839 13.9752 17.7164C13.5796 17.5938 13.3582 17.1736 13.4808 16.778C14.103 14.7703 15.8523 13.25 17.9906 13.25C19.9889 13.25 21.6507 14.5806 22.3646 16.3916C22.5165 16.777 22.3272 17.2125 21.9419 17.3644C21.5565 17.5163 21.121 17.3271 20.9691 16.9417C20.4454 15.6134 19.2809 14.75 17.9906 14.75Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.0001 13.7998C22.4143 13.7998 22.7501 14.1356 22.7501 14.5498V16.172C22.7501 16.9176 22.1457 17.522 21.4001 17.522H19.9951C19.5809 17.522 19.2451 17.1862 19.2451 16.772C19.2451 16.3578 19.5809 16.022 19.9951 16.022H21.2501V14.5498C21.2501 14.1356 21.5859 13.7998 22.0001 13.7998Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.0104 21.25C19.3889 21.25 20.6277 20.2613 21.0874 18.778C21.21 18.3823 21.6301 18.161 22.0258 18.2836C22.4214 18.4062 22.6428 18.8264 22.5201 19.222C21.898 21.2297 20.1486 22.75 18.0104 22.75C16.0121 22.75 14.3503 21.4194 13.6364 19.6084C13.4845 19.223 13.6737 18.7875 14.0591 18.6356C14.4444 18.4837 14.88 18.6729 15.0319 19.0583C15.5555 20.3866 16.72 21.25 18.0104 21.25Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.9999 22.2002C13.5857 22.2002 13.2499 21.8644 13.2499 21.4502V19.828C13.2499 19.0824 13.8543 18.478 14.5999 18.478H16.0049C16.4191 18.478 16.7549 18.8138 16.7549 19.228C16.7549 19.6422 16.4191 19.978 16.0049 19.978H14.7499V21.4502C14.7499 21.8644 14.4141 22.2002 13.9999 22.2002Z" fill="currentColor"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);