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="M9 6C7.34315 6 6 7.34315 6 9V39C6 40.6569 7.34315 42 9 42H14V39C14 38.4477 14.4477 38 15 38H19C19.5523 38 20 38.4477 20 39V42H27V39C27 38.4477 27.4477 38 28 38H32C32.5523 38 33 38.4477 33 39V42H39C40.6569 42 42 40.6569 42 39V9C42 7.34315 40.6569 6 39 6H9ZM33.9899 34.6349C34.5373 34.0802 35.0903 33.5198 35.6002 32.6853C35.7283 32.4755 35.8584 32.2739 35.9845 32.0785C36.4398 31.3727 36.8434 30.7471 36.9185 30.1074C37.0145 29.2905 37.0744 24.3909 36.8099 23.6494C36.5455 22.9079 35.0202 22.4924 34.4932 24.152C34.2332 24.971 34.1511 26.0243 34.0766 26.9795C34.0002 27.9602 33.9317 28.8377 33.6872 29.2521C33.2044 30.0703 31.6491 32.1046 31.6491 32.1046L32.9906 29.5582C32.9906 29.5582 33.1952 29.2056 33.0877 28.5365C32.9801 27.8675 32.1708 26.9312 31.7905 27.6748C31.4103 28.4184 30.7456 29.0888 30.7456 29.0888L28.3979 31.9175C28.3979 31.9175 27.6329 32.9098 27.612 33.4543C27.6049 33.6361 27.4911 34.0397 27.3622 34.4967C27.2166 35.0128 27.0519 35.5969 27 36.0068V37H32.7735V36.0068C33.1615 35.4743 33.5741 35.0562 33.9899 34.6349ZM14.1773 36.0068C13.788 35.4743 13.3741 35.0562 12.9569 34.6349C12.4076 34.0802 11.8528 33.5198 11.3412 32.6853C11.2126 32.4755 11.0821 32.2739 10.9556 32.0784C10.4988 31.3727 10.0938 30.7471 10.0185 30.1074C9.92219 29.2905 10.2209 24.3909 10.4863 23.6494C10.7516 22.9079 12.282 22.4924 12.8107 24.152C13.0716 24.971 13.154 26.0243 13.2287 26.9795C13.3054 27.9602 13.3741 28.8377 13.6194 29.2521C14.1039 30.0703 15.6643 32.1046 15.6643 32.1046L14.3183 29.5582C14.3183 29.5582 14.113 29.2056 14.2209 28.5365C14.3289 27.8675 15.1409 26.9312 15.5224 27.6748C15.904 28.4184 16.5708 29.0888 16.5708 29.0888L18.9264 31.9175C18.9264 31.9175 19.6939 32.9098 19.715 33.4543C19.7299 33.8414 19.9019 35.2339 20 36.0068V37H14.1773V36.0068ZM19.7812 11C17.018 11 15 13.9864 15 17.2069C15 24.3965 24 29 24 29C24 29 33 24.1 33 17.2069C33 13.9869 30.9823 11 28.2188 11C26.3011 11 24.8782 12.34 24 14.2406C23.1217 12.3399 21.6988 11 19.7812 11Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);