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="M12 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 6.06293 17.937 1.25 12 1.25ZM12.75 7C12.75 6.58579 12.4142 6.25 12 6.25C11.5858 6.25 11.25 6.58579 11.25 7V7.76724H7C6.58579 7.76724 6.25 8.10303 6.25 8.51724C6.25 8.93145 6.58579 9.26724 7 9.26724H12H14.1732C13.6612 10.593 12.8872 11.8763 11.9861 13.0775C11.8032 12.8448 11.6185 12.6014 11.4455 12.3638C11.0699 11.8481 10.7877 11.4125 10.6786 11.1806C10.5021 10.8058 10.0553 10.645 9.68056 10.8214C9.3058 10.9979 9.14501 11.4447 9.32143 11.8194C9.49796 12.1944 9.85867 12.733 10.233 13.2469C10.4846 13.5923 10.7599 13.9503 11.0242 14.2773C10.0039 15.4742 8.91148 16.5462 7.92369 17.4454C7.61738 17.7242 7.59512 18.1986 7.87396 18.5049C8.1528 18.8112 8.62715 18.8335 8.93345 18.5546C9.9105 17.6652 11.0029 16.5974 12.041 15.3957L13.605 17.0054C13.8936 17.3025 14.3685 17.3094 14.6655 17.0207C14.9626 16.7321 14.9695 16.2572 14.6808 15.9602L12.9966 14.2267C14.1463 12.7347 15.1673 11.0578 15.7674 9.26724H17C17.4142 9.26724 17.75 8.93145 17.75 8.51724C17.75 8.10303 17.4142 7.76724 17 7.76724H15.2143H12.75V7Z" fill="currentColor"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );