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="M14 29.9268C9.50005 29.2635 6 24.1767 6 18C6 11.3726 10.0294 6 15 6C19.9706 6 24 11.3726 24 18C24 24.1767 20.5 29.2635 16 29.9268V37H32V30.0457H27.2727C25.4653 30.0457 24 28.5805 24 26.773C24 25.4934 24.7344 24.3853 25.8047 23.8472C25.6952 23.4779 25.6364 23.0869 25.6364 22.6821C25.6364 20.9565 26.7048 19.4805 28.2161 18.8794C28.1342 18.5237 28.0909 18.1534 28.0909 17.7729C28.0909 15.0616 30.2887 12.8638 33 12.8638C35.7112 12.8638 37.909 15.0616 37.909 17.7729C37.909 18.1533 37.8658 18.5237 37.7839 18.8793C39.2953 19.4804 40.3637 20.9565 40.3637 22.6821C40.3637 23.0869 40.3049 23.478 40.1953 23.8472C41.2656 24.3853 42 25.4934 42 26.773C42 28.5805 40.5348 30.0457 38.7273 30.0457H34V37H39.5C40.8807 37 42 38.1193 42 39.5C42 40.8807 40.8807 42 39.5 42H8.5C7.11929 42 6 40.8807 6 39.5C6 38.1193 7.11929 37 8.5 37H14L14 29.9268ZM22 18C22 20.9228 21.109 23.4919 19.764 25.2853C18.6818 26.7282 17.3662 27.607 16 27.8951V24.5H14V27.8951C12.6338 27.607 11.3182 26.7282 10.236 25.2853C8.89104 23.4919 8 20.9228 8 18C8 15.0772 8.89104 12.5081 10.236 10.7147C11.5806 8.922 13.2854 8 15 8C16.7146 8 18.4194 8.922 19.764 10.7147C21.109 12.5081 22 15.0772 22 18ZM35.8349 18.4304L35.4495 20.1033L37.0447 20.7377C37.8208 21.0464 38.3637 21.8032 38.3637 22.6821C38.3637 22.8923 38.3333 23.0919 38.2779 23.2785L37.8022 24.8826L39.297 25.6341C39.7181 25.8458 40 26.2783 40 26.773C40 27.4759 39.4302 28.0457 38.7273 28.0457H34V25.5H32V28.0457H27.2727C26.5698 28.0457 26 27.4759 26 26.773C26 26.2783 26.2819 25.8458 26.703 25.6341L28.1979 24.8826L27.7222 23.2785C27.6668 23.0919 27.6364 22.8923 27.6364 22.6821C27.6364 21.8033 28.1792 21.0464 28.9553 20.7378L30.5504 20.1033L30.165 18.4304C30.1168 18.221 30.0909 18.0012 30.0909 17.7729C30.0909 16.1662 31.3933 14.8638 33 14.8638C34.6066 14.8638 35.909 16.1662 35.909 17.7729C35.909 18.0012 35.8831 18.221 35.8349 18.4304ZM8 39.5C8 39.2239 8.22386 39 8.5 39H39.5C39.7761 39 40 39.2239 40 39.5C40 39.7761 39.7761 40 39.5 40H8.5C8.22386 40 8 39.7761 8 39.5Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);