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="M22.5 6C23.3284 6 24 6.67157 24 7.5V23H26V10.5C26 9.67157 26.6716 9 27.5 9C28.3284 9 29 9.67157 29 10.5V26.0855C29 27.9898 31.4096 28.8165 32.5787 27.3133L35.7652 23.2164C36.3798 22.4262 37.5775 22.4367 38.1782 23.2376C38.5503 23.7338 38.5832 24.4064 38.2613 24.9366L31.0573 36.7992C29.0962 40.0283 25.5921 42 21.8141 42C15.8416 42 11 37.1584 11 31.1859V16.5C11 15.6716 11.6716 15 12.5 15C13.3284 15 14 15.6716 14 16.5V25.1176H16V10.5C16 9.67157 16.6716 9 17.5 9C18.3284 9 19 9.67157 19 10.5V23H21V7.5C21 6.67157 21.6716 6 22.5 6ZM19.0037 7.33856C19.088 5.4805 20.6211 4 22.5 4C24.3789 4 25.912 5.4805 25.9963 7.33856C26.4519 7.1215 26.9618 7 27.5 7C29.433 7 31 8.567 31 10.5V26.0855L34.1865 21.9885C35.6107 20.1574 38.3863 20.1817 39.7782 22.0376C40.6406 23.1874 40.7168 24.7462 39.9707 25.9747L32.7667 37.8373C30.443 41.6637 26.2908 44 21.8141 44C14.7371 44 9 38.2629 9 31.1859V16.5C9 14.567 10.567 13 12.5 13C13.0368 13 13.5454 13.1208 14 13.3368V10.5C14 8.567 15.567 7 17.5 7C18.0382 7 18.5481 7.1215 19.0037 7.33856Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);