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" stroke-width="1.5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12 2.0001C11.4841 1.45573 11.4838 1.45597 11.4838 1.45597L12 2.0001ZM12.5166 1.45637L12.518 1.4577L12.523 1.46243L12.5414 1.48003L12.611 1.54694C12.6714 1.60531 12.7592 1.69079 12.8706 1.80076C13.0934 2.02066 13.4105 2.33872 13.7906 2.73389C14.5499 3.52338 15.5643 4.62469 16.5808 5.8687C17.5949 7.10988 18.6242 8.50898 19.4035 9.89319C20.1716 11.2573 20.75 12.6983 20.75 14.0001C20.75 18.8326 16.8325 22.7501 12 22.7501C7.16751 22.7501 3.25 18.8326 3.25 14.0001C3.25 12.6983 3.82845 11.2573 4.59646 9.89319C5.3758 8.50898 6.40507 7.10988 7.41922 5.8687C8.43569 4.62469 9.45014 3.52338 10.2094 2.73389C10.5895 2.33872 10.9066 2.02066 11.1294 1.80076C11.2408 1.69079 11.3286 1.60531 11.389 1.54694L11.4586 1.48003L11.477 1.46243L11.4838 1.45597L12 0.966797L12.5166 1.45637ZM12 2.0001L12.5166 1.45637C12.5166 1.45637 12.5159 1.45573 12 2.0001ZM12.7501 10.0001C12.7501 9.58589 12.4143 9.2501 12.0001 9.2501C11.5859 9.2501 11.2501 9.58589 11.2501 10.0001V12.1943L9.37803 11.1023C9.02024 10.8936 8.561 11.0144 8.35229 11.3722C8.14358 11.73 8.26443 12.1892 8.62222 12.3979L10.5116 13.5001L8.62222 14.6023C8.26443 14.811 8.14358 15.2702 8.35229 15.628C8.561 15.9858 9.02024 16.1066 9.37803 15.8979L11.2501 14.8059V17.0001C11.2501 17.4143 11.5859 17.7501 12.0001 17.7501C12.4143 17.7501 12.7501 17.4143 12.7501 17.0001V14.8059L14.6222 15.8979C14.98 16.1066 15.4392 15.9858 15.648 15.628C15.8567 15.2702 15.7358 14.811 15.378 14.6023L13.4886 13.5001L15.378 12.3979C15.7358 12.1892 15.8567 11.73 15.648 11.3722C15.4392 11.0144 14.98 10.8936 14.6222 11.1023L12.7501 12.1943V10.0001Z" fill="currentColor"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );