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="M28 8C28 10.2091 26.2091 12 24 12C21.7909 12 20 10.2091 20 8C20 5.79086 21.7909 4 24 4C26.2091 4 28 5.79086 28 8Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.8256 15.0773C15.1698 14.4153 15.8539 14 16.6 14H29.0184C31.1404 14 32.9102 14.7416 34.1536 16.0013C35.3754 17.239 35.9842 18.8719 35.9997 20.4808C36.0152 22.0911 35.436 23.7407 34.2068 24.9941C33.1528 26.0688 31.715 26.7579 30 26.9471V42C30 43.0747 29.1507 43.9573 28.0768 43.9985C27.0028 44.0398 26.0883 43.2249 26.0059 42.1534L25.1354 30.8366C26.7915 30.3472 28 28.8147 28 27C28 24.7909 26.2091 23 24 23C23.4175 23 22.8641 23.1245 22.365 23.3483C22.1696 22.7726 21.7999 22.2301 21.2513 21.7625C20.2485 20.9077 19.3691 20.1845 18.74 19.6747C18.4259 19.4201 18.174 19.2186 18 19.0802V18H17.8142L16.6465 20.2457L16.4947 20.4396L16.5106 20.4521L16.5602 20.4911C16.6041 20.5258 16.6694 20.5775 16.7543 20.6449C16.9239 20.7798 17.1713 20.9777 17.4808 21.2285C18.0998 21.7302 18.9662 22.4426 19.9539 23.2846C20.4596 23.7156 20.562 24.1367 20.5219 24.4839C20.4767 24.8756 20.2288 25.3225 19.7768 25.6823C19.0482 26.2623 17.9383 26.5037 16.8688 25.8563L12.7506 22.5617C12.0049 21.9652 11.785 20.9246 12.2256 20.0773L14.8256 15.0773ZM20.0847 27.8229C19.4522 28.1137 18.738 28.2693 18 28.2381V42C18 43.0747 18.8493 43.9573 19.9232 43.9985C20.9972 44.0398 21.9117 43.2249 21.9941 42.1534L22.8646 30.8366C21.4659 30.4233 20.3865 29.2659 20.0847 27.8229ZM24 29C25.1046 29 26 28.1046 26 27C26 25.8954 25.1046 25 24 25C22.8954 25 22 25.8954 22 27C22 28.1046 22.8954 29 24 29ZM30 18.1075V22.8998C30.6409 22.7569 31.0697 22.4801 31.3509 22.1934C31.7767 21.7593 32.006 21.1589 31.9999 20.5192C31.9937 19.8781 31.7508 19.261 31.3069 18.8112C31.0203 18.5209 30.601 18.251 30 18.1075Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);