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="M9.29285 9.29289C9.68337 8.90237 10.3165 8.90237 10.7071 9.29289L15.1478 13.7337C17.7562 12.6798 20.7209 12 24 12C32.8659 12 39.4335 16.97 42.8736 20.8642C44.4683 22.6695 44.4683 25.3305 42.8736 27.1358C41.0337 29.2186 38.2991 31.6092 34.7966 33.3825L38.7071 37.2929C39.0976 37.6834 39.0976 38.3166 38.7071 38.7071C38.3165 39.0976 37.6834 39.0976 37.2928 38.7071L32.8521 34.2663C30.2437 35.3202 27.279 36 24 36C15.134 36 8.56639 31.03 5.12635 27.1358C3.53161 25.3305 3.53161 22.6695 5.12635 20.8642C6.96626 18.7814 9.70085 16.3908 13.2033 14.6175L9.29285 10.7071C8.90232 10.3166 8.90232 9.68342 9.29285 9.29289ZM10.0256 19C10.925 18.2984 11.9177 17.6195 12.9981 17L13 17H15.5857L17.5857 19L10.0256 19ZM7.77526 20.9747C7.35889 21.3853 6.97521 21.7921 6.62527 22.1883C6.40609 22.4364 6.23875 22.7112 6.12326 23L21.5857 23L19.5857 21L7.99996 21C7.92269 21 7.84748 20.9912 7.77526 20.9747ZM6.62527 25.8117C6.40609 25.5636 6.23875 25.2888 6.12326 25L23.5857 25L25.5857 27H7.99996C7.9227 27 7.84748 27.0088 7.77526 27.0253C7.35889 26.6147 6.97521 26.2079 6.62527 25.8117ZM10.0256 29C10.925 29.7016 11.9177 30.3805 12.9981 31L13 31L29.5857 31L27.5857 29H10.0256ZM24 34C21.6707 34 19.5094 33.6233 17.5357 33L30.4642 33C28.4905 33.6233 26.3292 34 24 34ZM28.8907 27.4765L31.7432 30.3291C34.9701 26.3907 34.7345 20.5697 31.0491 16.9071C27.3786 13.2593 21.5886 13.0467 17.6709 16.2568L20.5234 19.1092C21.5042 18.4108 22.7041 18 23.9999 18C24.9262 18 25.8035 18.2099 26.5868 18.5848C26.2243 18.9468 26 19.4472 26 20C26 21.1046 26.8954 22 28 22C28.5528 22 29.0532 21.7757 29.4152 21.4132C29.79 22.1965 29.9999 23.0737 29.9999 24C29.9999 25.2958 29.5891 26.4957 28.8907 27.4765ZM33.1633 31.7492L33.3012 31.8871C36.8093 30.2338 39.5504 27.8768 41.3746 25.8117C42.3013 24.7628 42.3013 23.2372 41.3746 22.1883C39.4757 20.0386 36.5832 17.5726 32.8664 15.9134C36.9407 20.3733 37.0444 27.17 33.1633 31.7492Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );