build method

  1. @override
Widget build(
  1. BuildContext context
)
override

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:

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="M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44ZM10.745 21.3088C11.9252 22.8359 15.372 22.1495 18.4437 19.7757C21.5154 17.4019 23.0489 14.2396 21.8687 12.7125C20.6886 11.1854 17.2418 11.8718 14.1701 14.2456C11.0983 16.6194 9.5649 19.7817 10.745 21.3088ZM32.4393 26.8501C35.7259 28.8346 37.5904 31.7679 36.6039 33.4018C35.6173 35.0357 32.1532 34.7516 28.8666 32.7671C25.58 30.7827 23.7155 27.8494 24.702 26.2155C25.6886 24.5815 29.1527 24.8657 32.4393 26.8501ZM33.2707 22.8553C35.0199 22.0371 35.1036 18.5216 33.4578 15.0033C31.812 11.485 29.0598 9.29611 27.3107 10.1143C25.5615 10.9326 25.4778 14.448 27.1236 17.9664C28.7694 21.4847 31.5216 23.6735 33.2707 22.8553ZM21.62 29.9331C23.4041 33.4821 23.4201 37.0783 21.6556 37.9652C19.8912 38.8522 17.0145 36.6942 15.2304 33.1451C13.4463 29.596 13.4304 25.9999 15.1948 25.1129C16.9592 24.2259 19.8359 26.384 21.62 29.9331Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );