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="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2 20V2H4V13.6115L6.17941 11.432C6.43309 12.0632 6.93684 12.567 7.56803 12.8207L4 16.3889V20H22V22H4C2.89543 22 2 21.1046 2 20Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.587 12.1232C17.848 12.518 18 12.9913 18 13.5C18 14.8807 16.8807 16 15.5 16C14.1194 16 13.0001 14.8808 13 13.5002C13 13.517 13.0002 13.5338 13.0005 13.5506L10.1874 12.3449C10.6868 11.8878 11 11.2306 11 10.5002C11 10.4833 10.9998 10.4664 10.9995 10.4496L13.8127 11.6553C14.2574 11.2483 14.8497 11 15.5 11C15.6601 11 15.8166 11.015 15.9683 11.0438L17.4129 8.87695C17.7781 9.4295 18.3569 9.82852 19.0316 9.95642L17.587 12.1232ZM16 13.5C16 13.7761 15.7761 14 15.5 14C15.2239 14 15 13.7761 15 13.5C15 13.2239 15.2239 13 15.5 13C15.7761 13 16 13.2239 16 13.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.9995 10.4496C10.9726 9.09214 9.86387 8 8.5 8C7.11929 8 6 9.11929 6 10.5C6 11.8807 7.11929 13 8.5 13C9.88071 13 11 11.8809 11 10.5002C11 10.4833 10.9998 10.4664 10.9995 10.4496ZM9 10.5C9 10.7761 8.77614 11 8.5 11C8.22386 11 8 10.7761 8 10.5C8 10.2239 8.22386 10 8.5 10C8.77614 10 9 10.2239 9 10.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.5 10C20.8807 10 22 8.88071 22 7.5C22 6.11929 20.8807 5 19.5 5C18.1193 5 17 6.11929 17 7.5C17 8.88071 18.1193 10 19.5 10ZM19.5 8C19.7761 8 20 7.77614 20 7.5C20 7.22386 19.7761 7 19.5 7C19.2239 7 19 7.22386 19 7.5C19 7.77614 19.2239 8 19.5 8Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);