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="M27 27.8397C24.3764 27.8299 21.9546 26.9635 20 25.5056V41C20 41.5523 20.4477 42 21 42H26C26.5523 42 27 41.5523 27 41V27.8397Z" fill="black"/>
<path d="M26 18H21.3951C22.2004 20.3274 24.4033 22.0025 27 22.0215V19C27 18.4477 26.5523 18 26 18Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.1128 24.0275C18.6775 22.2148 17.1001 19.3141 17.1001 16.0449C17.1001 10.5525 21.5526 6.1001 27.045 6.1001C32.5374 6.1001 36.9899 10.5525 36.9899 16.0449C36.9899 18.1817 36.3161 20.1609 35.1693 21.7818L35.1206 21.8507L40.8587 27.5886L39.361 29.0863L33.7053 23.4307L33.6349 23.4931C31.8802 25.0467 29.5729 25.9897 27.045 25.9897C27.03 25.9897 27.015 25.9897 27 25.9896V25.9999C24.7584 25.9903 22.7309 25.2607 21.1128 24.0275ZM34.8719 16.0449C34.8719 20.3675 31.3676 23.8717 27.045 23.8717C22.7224 23.8717 19.2182 20.3675 19.2182 16.0449C19.2182 11.7223 22.7224 8.21813 27.045 8.21813C31.3676 8.21813 34.8719 11.7223 34.8719 16.0449Z" fill="black"/>
<path d="M9 6C8.44772 6 8 6.44772 8 7V41C8 41.5523 8.44772 42 9 42H14C14.5523 42 15 41.5523 15 41V7C15 6.44772 14.5523 6 14 6H9Z" fill="black"/>
<path d="M32 33C32 32.4477 32.4477 32 33 32H38C38.5523 32 39 32.4477 39 33V41C39 41.5523 38.5523 42 38 42H33C32.4477 42 32 41.5523 32 41V33Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);