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 d="M27.2929 17.2929C27.6834 16.9024 28.3166 16.9024 28.7071 17.2929L30.5 19.0858L32.2929 17.2929C32.6834 16.9024 33.3166 16.9024 33.7071 17.2929C34.0976 17.6834 34.0976 18.3166 33.7071 18.7071L31.9142 20.5L33.7071 22.2929C34.0976 22.6834 34.0976 23.3166 33.7071 23.7071C33.3166 24.0976 32.6834 24.0976 32.2929 23.7071L30.5 21.9142L28.7071 23.7071C28.3166 24.0976 27.6834 24.0976 27.2929 23.7071C26.9024 23.3166 26.9024 22.6834 27.2929 22.2929L29.0858 20.5L27.2929 18.7071C27.2441 18.6583 27.2014 18.6057 27.1648 18.5502C26.9085 18.1621 26.9512 17.6346 27.2929 17.2929Z" fill="black"/>
<path d="M14.2929 17.2929C14.6834 16.9024 15.3166 16.9024 15.7071 17.2929L17.5 19.0858L19.2929 17.2929C19.6834 16.9024 20.3166 16.9024 20.7071 17.2929C21.0976 17.6834 21.0976 18.3166 20.7071 18.7071L18.9142 20.5L20.7071 22.2929C20.7559 22.3417 20.7986 22.3943 20.8352 22.4498C21.0915 22.8379 21.0488 23.3654 20.7071 23.7071C20.3166 24.0976 19.6834 24.0976 19.2929 23.7071L17.5 21.9142L15.7079 23.7063L15.7071 23.7071C15.3166 24.0976 14.6834 24.0976 14.2929 23.7071C13.9024 23.3166 13.9024 22.6834 14.2929 22.2929L16.0858 20.5L14.2929 18.7071C14.2441 18.6583 14.2014 18.6057 14.1648 18.5502C13.9085 18.1621 13.9512 17.6346 14.2929 17.2929Z" fill="black"/>
<path d="M31 32C31 35.3137 27.866 36 24 36C20.134 36 17 35.3137 17 32C17 28.6863 20.134 26 24 26C27.866 26 31 28.6863 31 32Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 42C33.9411 42 42 33.9411 42 24C42 14.0589 33.9411 6 24 6C14.0589 6 6 14.0589 6 24C6 33.9411 14.0589 42 24 42ZM24 40C32.8366 40 40 32.8366 40 24C40 15.1634 32.8366 8 24 8C15.1634 8 8 15.1634 8 24C8 32.8366 15.1634 40 24 40Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);