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="M25.5039 10.3361C26.2372 9.23616 27.6041 8.74586 28.8694 9.12896C30.1346 9.51205 31 10.6782 31 12.0002V27.0003H32C33.6569 27.0003 35 28.3434 35 30.0003C35 31.6571 33.6569 33.0003 32 33.0003H31V36.0002C31 37.6571 29.6569 39.0002 28 39.0002C26.3432 39.0002 25 37.6571 25 36.0002V33.0003H16C14.8936 33.0003 13.877 32.3913 13.355 31.4158L14.2305 30.9473L13.355 31.4158C12.8329 30.4404 12.8901 29.2567 13.5039 28.3362L25.5039 10.3361ZM28.2898 11.0431C27.868 10.9154 27.4124 11.0789 27.168 11.4455L15.168 29.4456C14.9634 29.7524 14.9443 30.147 15.1183 30.4721C15.2923 30.7973 15.6312 31.0003 16 31.0003H26C26.5523 31.0003 27 31.448 27 32.0003V36.0002C27 36.5525 27.4477 37.0002 28 37.0002C28.5523 37.0002 29 36.5525 29 36.0002V32.0003C29 31.448 29.4477 31.0003 30 31.0003H32C32.5523 31.0003 33 30.5525 33 30.0003C33 29.448 32.5523 29.0003 32 29.0003H30C29.4477 29.0003 29 28.5525 29 28.0003V12.0002C29 11.5596 28.7115 11.1708 28.2898 11.0431ZM26.2898 17.6487C26.7115 17.7764 27 18.1651 27 18.6058V28.0003C27 28.5525 26.5523 29.0003 26 29.0003H19.737C19.3682 29.0003 19.0294 28.7973 18.8554 28.4721C18.6813 28.147 18.7004 27.7524 18.905 27.4456L25.168 18.0511C25.4124 17.6844 25.868 17.521 26.2898 17.6487ZM21.6056 27.0003H25V21.9086L21.6056 27.0003Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);