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="M18.2597 10.1418C21.0006 9.0065 24.0166 8.70945 26.9264 9.28823C29.8361 9.86701 32.5088 11.2956 34.6066 13.3934C35.7782 14.565 35.7782 16.4645 34.6066 17.636C33.435 18.8076 31.5355 18.8076 30.364 17.636C29.1053 16.3774 27.5016 15.5202 25.7558 15.1729C24.01 14.8257 22.2004 15.0039 20.5559 15.6851C18.9113 16.3663 17.5057 17.5198 16.5168 18.9999C15.5278 20.4799 15 22.22 15 24C15 25.78 15.5278 27.5201 16.5168 29.0001C17.5057 30.4802 18.9113 31.6337 20.5559 32.3149C22.2004 32.9961 24.01 33.1743 25.7558 32.8271C27.5016 32.4798 29.1053 31.6226 30.364 30.364C31.5355 29.1924 33.435 29.1924 34.6066 30.364C35.7782 31.5355 35.7782 33.435 34.6066 34.6066C32.5088 36.7044 29.8361 38.133 26.9264 38.7118C24.0166 39.2906 21.0006 38.9935 18.2598 37.8582C15.5189 36.7229 13.1762 34.8003 11.528 32.3336C9.87974 29.8668 9 26.9667 9 24C9 21.0333 9.87973 18.1332 11.528 15.6665C13.1762 13.1997 15.5189 11.2771 18.2597 10.1418ZM26.5362 11.2498C24.0144 10.7482 21.4006 11.0056 19.0251 11.9896C16.6497 12.9735 14.6194 14.6398 13.1909 16.7776C11.7624 18.9154 11 21.4289 11 24C11 26.5712 11.7624 29.0846 13.1909 31.2224C14.6194 33.3603 16.6497 35.0265 19.0251 36.0104C21.4006 36.9944 24.0144 37.2518 26.5362 36.7502C29.0579 36.2486 31.3743 35.0105 33.1924 33.1924C33.5829 32.8019 33.5829 32.1687 33.1924 31.7782C32.8019 31.3877 32.1687 31.3877 31.7782 31.7782C30.2398 33.3166 28.2798 34.3642 26.146 34.7886C24.0122 35.2131 21.8005 34.9952 19.7905 34.1627C17.7805 33.3301 16.0625 31.9202 14.8538 30.1113C13.6451 28.3023 13 26.1756 13 24C13 21.8244 13.6451 19.6977 14.8538 17.8887C16.0625 16.0798 17.7805 14.6699 19.7905 13.8373C21.8005 13.0048 24.0122 12.7869 26.146 13.2114C28.2798 13.6358 30.2398 14.6835 31.7782 16.2218C32.1687 16.6124 32.8019 16.6124 33.1924 16.2218C33.5829 15.8313 33.5829 15.1981 33.1924 14.8076C31.3743 12.9895 29.0579 11.7514 26.5362 11.2498Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );