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="M13.0868 6.8462C14.1871 6.17163 15.4411 6 16.5578 6H33V15C30.2386 15 28 17.2386 28 20V25C28 27.7614 30.2386 30 33 30C35.7614 30 38 27.7614 38 25V20C38 17.9497 36.7659 16.1876 35 15.416V6H39.0001C40.6569 6 42.0001 7.34315 42.0001 9V25.9995C42.0001 30.7097 37.4603 33.9995 33.0001 33.9995C28.5399 33.9995 24.0001 30.7097 24.0001 25.9995V17.1392C23.4028 17.2975 22.7913 17.5849 22.2682 17.9737C21.4332 18.5944 21.0001 19.3314 21.0001 19.9995V28.9994C21.7557 29.3574 22.3131 29.8267 22.6413 30.5098C23.001 31.2583 23.0005 32.1368 23.0001 32.9188L23.0001 32.9995C23.0001 35.1884 22.1198 37.411 20.7173 39.0903C19.3141 40.7704 17.3039 41.9995 15.0001 41.9995C12.6962 41.9995 10.686 40.7704 9.28279 39.0903C7.8803 37.411 7.00006 35.1884 7.00006 32.9995L7.00003 32.9188C6.9996 32.1367 6.99911 31.2583 7.35877 30.5098C7.68697 29.8267 8.24444 29.3574 9.00006 28.9994V13.9995C9.00006 10.815 10.6517 8.3392 13.0868 6.8462Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);