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="M1.25 16.5C1.25 13.0482 4.04822 10.25 7.5 10.25C10.9518 10.25 13.75 13.0482 13.75 16.5C13.75 19.9518 10.9518 22.75 7.5 22.75C6.4644 22.75 5.48586 22.4976 4.6244 22.0505L2.41228 22.4623C2.16923 22.5076 1.91949 22.4301 1.74467 22.2553C1.56985 22.0805 1.49242 21.8308 1.53767 21.5877L1.94953 19.3756C1.50244 18.5141 1.25 17.5356 1.25 16.5Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.7499 10C22.7499 5.16751 18.8325 1.25 13.9999 1.25C9.73442 1.25 5.90197 4.4993 5.33758 8.7588C5.33709 8.76059 5.33669 8.76183 5.33638 8.76263C5.33741 8.74858 5.33662 8.75058 5.33597 8.75509C5.33532 8.75961 5.33481 8.76664 5.33638 8.76263C5.33561 8.77306 5.33385 8.79231 5.33029 8.82591C5.32628 8.86551 5.32098 8.92185 5.3153 8.99325C5.31354 9.01533 5.31174 9.03885 5.30994 9.06378C6.00443 8.85957 6.73944 8.75 7.50004 8.75C11.7803 8.75 15.25 12.2198 15.25 16.5C15.25 17.2591 15.1409 17.9927 14.9375 18.6859C15.0164 18.6798 15.086 18.6736 15.1454 18.6678C15.2187 18.6607 15.2765 18.6542 15.3171 18.6493L15.365 18.6434L15.3789 18.6416L15.3832 18.641L15.3848 18.6408L15.3859 18.6406L15.4016 18.6383C16.3735 18.4817 17.2918 18.165 18.1285 17.7165L21.4627 18.3373C21.7057 18.3826 21.9555 18.3051 22.1303 18.1303C22.3051 17.9555 22.3825 17.7058 22.3373 17.4627L21.7165 14.1285C22.3761 12.8981 22.7499 11.4917 22.7499 10Z" fill="currentColor"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);