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="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="M19.7727 8.95472L19.2424 8.42441L18.7121 8.95472C17.8334 9.8334 16.4088 9.83341 15.5301 8.95473C14.6514 8.07606 14.6514 6.65143 15.5301 5.77275L16.0604 5.24241L15.5301 4.71208C14.7283 3.91023 14.6581 2.65374 15.3198 1.77239C14.2742 1.43327 13.1585 1.25 12 1.25C6.06294 1.25 1.25 6.06294 1.25 12C1.25 13.8563 1.72113 15.6046 2.55076 17.1298L1.76267 21.3627C1.71742 21.6058 1.79485 21.8555 1.96967 22.0303C2.14448 22.2051 2.39422 22.2826 2.63727 22.2373L6.87016 21.4493C8.39536 22.2788 10.1437 22.75 12 22.75C17.937 22.75 22.75 17.937 22.75 12C22.75 11.0857 22.6359 10.198 22.421 9.3505C21.5702 9.80366 20.4897 9.67173 19.7727 8.95472Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M16.5908 2.59076C16.8837 2.29787 17.3585 2.29787 17.6514 2.59077L19.2424 4.18175L20.8334 2.59077C21.1263 2.29787 21.6011 2.29787 21.894 2.59076C22.1869 2.88365 22.1869 3.35853 21.894 3.65142L20.303 5.24241L21.894 6.83341C22.1869 7.1263 22.1869 7.60117 21.894 7.89407C21.6011 8.18696 21.1263 8.18696 20.8334 7.89406L19.2424 6.30308L17.6514 7.89406C17.3585 8.18696 16.8837 8.18696 16.5908 7.89407C16.2979 7.60117 16.2979 7.1263 16.5908 6.83341L18.1817 5.24241L16.5908 3.65142C16.2979 3.35853 16.2979 2.88365 16.5908 2.59076Z" fill="currentColor"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );