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.6461 26.4968C27.2656 26.4968 26.1466 27.6159 26.1466 28.9963H28.1466C28.1466 28.7204 28.3702 28.4968 28.6461 28.4968H28.731C29.0538 28.4968 29.3154 28.7585 29.3154 29.0812V37.0558C29.3154 37.6081 29.7631 38.0558 30.3154 38.0558C30.8677 38.0558 31.3154 37.6081 31.3154 37.0558V29.0812C31.3154 27.6539 30.1583 26.4968 28.731 26.4968H28.6461Z" fill="black"/>
<path d="M17.9317 29.8952L18 30.02V36C18 37.1046 18.8954 38 20 38C21.1046 38 22 37.1046 22 36V29.5C22 27.3021 22.5113 25.1921 23.1794 23.4259L23.3947 24.2747C23.5849 25.0245 24.1904 25.5974 24.9495 25.7459L28.6162 26.4628C29.7002 26.6748 30.7509 25.9678 30.9628 24.8838C31.1748 23.7998 30.4678 22.7491 29.3838 22.5372L26.9605 22.0633L25.8053 17.5083C25.5803 16.6212 24.7819 16 23.8667 16C20.8662 16 18.8539 17.8471 17.6932 19.68C16.5583 21.4722 16 23.5895 16 25C16 25.4045 16.0916 25.7805 16.1629 26.0299C16.2429 26.3098 16.3472 26.597 16.4555 26.8678C16.6726 27.4104 16.9502 27.9976 17.2111 28.5194C17.475 29.0472 17.7369 29.5381 17.9317 29.8952Z" fill="black"/>
<path d="M29.5 18C31.433 18 33 16.433 33 14.5C33 12.567 31.433 11 29.5 11C27.567 11 26 12.567 26 14.5C26 16.433 27.567 18 29.5 18Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6 9C6 7.34315 7.34315 6 9 6H39C40.6569 6 42 7.34315 42 9V39C42 40.6569 40.6569 42 39 42H9C7.34315 42 6 40.6569 6 39V9ZM8 9C8 8.44772 8.44771 8 9 8H39C39.5523 8 40 8.44771 40 9V39C40 39.5523 39.5523 40 39 40H9C8.44772 40 8 39.5523 8 39V9Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);