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="M37.6381 27.8114C37.3954 27.9413 37.1238 28.0089 36.848 28.008H34.9133L34.7586 36H33.4634C30.9635 36 28.5597 34.9767 26.7824 33.1448C25.0042 31.3119 24 28.8197 24 26.2149V14H33.6746C33.7613 14.3357 33.8233 14.6752 33.8218 14.9069L34.0153 18.0739C34.0153 18.0739 36.7428 22.1093 38.3623 25.7041C38.4745 25.9538 38.5219 26.2275 38.5 26.5C38.4782 26.7725 38.3879 27.0353 38.2374 27.2644C38.0868 27.4935 37.8808 27.6815 37.6381 27.8114ZM32.7999 12H35.021C36.8819 12 38.6602 12.7623 39.9665 14.1088C41.2719 15.4542 42 17.2728 42 19.1629V38H34.7198L34.7586 36H40V19.1629C40 17.784 39.4683 16.4675 38.5311 15.5014C37.5948 14.5364 36.3316 14 35.021 14H33.6746C33.586 13.6564 33.4715 13.3167 33.3728 13.1006C33.1936 12.7153 33.0028 12.3487 32.7999 12ZM32.7999 12H22V12.1007H8.59568C11.8123 7.50879 17.6312 5.07418 23.944 6.32729C28.148 7.16283 30.9666 8.84925 32.7999 12ZM7.4279 14.1007L22 14.1007V19.3256H6.03734C6.19099 17.4312 6.67455 15.6751 7.4279 14.1007ZM6 21.3256H22V26.2149C22 29.3309 23.2007 32.3251 25.347 34.5374C26.6587 35.8895 28.2584 36.8818 30.0001 37.4494V38H27.5359V42H10.9585V31.6572C9.37758 30.2587 8.11604 28.5416 7.25831 26.6209C6.51046 24.9462 6.08461 23.1504 6 21.3256Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);