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 fill-rule="evenodd" clip-rule="evenodd" d="M13.6672 1.71213C13.8263 1.32969 14.2653 1.14863 14.6477 1.30772C15.0302 1.46682 15.2112 1.90582 15.0521 2.28826L14.0121 4.78826C13.8531 5.17071 13.414 5.35176 13.0316 5.19267C12.6492 5.03357 12.4681 4.59457 12.6272 4.21213L13.6672 1.71213ZM17.3136 1.6973C17.4808 1.31837 17.9236 1.1468 18.3026 1.31408C18.6815 1.48137 18.8531 1.92416 18.6858 2.30309L15.251 10.0834C17.3366 11.2319 18.7497 13.451 18.7497 16.0002C18.7497 19.7281 15.7276 22.7502 11.9997 22.7502C8.27175 22.7502 5.24968 19.7281 5.24968 16.0002C5.24968 13.6261 6.47537 11.5382 8.32849 10.3349L4.32886 2.33561C4.14361 1.96512 4.29378 1.51462 4.66427 1.32938C5.03475 1.14413 5.48525 1.2943 5.6705 1.66479L9.66966 9.66314C10.2603 9.44589 10.8898 9.30887 11.5448 9.26528L8.16062 2.32906C7.979 1.9568 8.13354 1.50777 8.50581 1.32614C8.87808 1.14452 9.3271 1.29906 9.50873 1.67133L13.2641 9.36843C13.4675 9.40697 13.6676 9.45463 13.8641 9.51097L17.3136 1.6973ZM12.0499 12.9C12.2771 12.7296 12.5812 12.7021 12.8353 12.8292C13.0894 12.9562 13.2499 13.2159 13.2499 13.5V18.5C13.2499 18.9142 12.9141 19.25 12.4999 19.25C12.0856 19.25 11.7499 18.9142 11.7499 18.5V15L10.9499 15.6C10.6185 15.8485 10.1484 15.7814 9.89986 15.45C9.65134 15.1186 9.71849 14.6485 10.0499 14.4L12.0499 12.9Z" fill="currentColor"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);