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="M7 22.9998C6.44772 22.9998 6 23.4475 6 23.9998V25L14.7936 24.9998C15.1499 24.9998 15.5432 25.0512 15.9851 25.1321C15.9948 25.5813 15.9999 26.0376 15.9999 26.4998C15.9999 28.7491 15.881 30.8597 15.673 32.6831C14.8165 32.8932 13.9368 32.9998 13.0527 32.9998L6 33V33.9998C6 34.5521 6.44772 34.9998 7 34.9998H13.0527C13.8313 34.9998 14.607 34.9299 15.3707 34.7915C14.9127 37.3729 14.2443 38.9998 13.4999 38.9998C12.9996 38.9998 12.5336 38.265 12.1428 36.9996L10.063 36.9997C10.2485 37.6988 10.465 38.3359 10.7187 38.8724C10.9165 39.2908 11.1865 39.7558 11.5657 40.1437C11.9482 40.5351 12.5999 40.9998 13.4999 40.9998C14.3998 40.9998 15.0515 40.5351 15.434 40.1437C15.8132 39.7558 16.0832 39.2908 16.281 38.8724C16.6815 38.0253 16.9895 36.9274 17.2288 35.7308C17.3232 35.2589 17.41 34.7554 17.4886 34.2244L21.1623 32.9998H23C23.9364 32.9998 24.7225 32.3563 24.9401 31.4874C25.1719 31.3779 25.5175 31.2475 25.9624 31.0952C28.3548 30.2763 30.4069 28.7408 31.8656 26.6743L35.6953 21.2488L40.5145 18.3573C40.7727 18.2024 40.9474 17.9393 40.9899 17.6412L41.9899 10.6412C42.0416 10.2798 41.8921 9.91889 41.6 9.69981L41.2237 9.41758C39.8844 8.41312 37.9822 8.69916 36.9975 10.0531L36.5667 10.6453C36.4119 10.4203 36.2238 10.213 36.0032 10.031L35.6364 9.72843C35.4298 9.55799 35.1635 9.47755 34.8971 9.50512C34.6307 9.53269 34.3864 9.66598 34.2191 9.87511L31.0957 13.7795C30.3864 14.666 30 15.7676 30 16.9029V18.2923L24.5344 20.2213C22.9921 20.7657 21.774 21.907 20.7535 22.8632C20.6063 23.0011 20.4633 23.1351 20.3239 23.263C19.919 23.6345 19.3219 23.7158 18.2636 23.5446C18.1512 23.5264 18.0402 23.5067 17.9291 23.4857C17.8162 21.1255 17.5725 18.9872 17.2288 17.2687C16.9895 16.0721 16.6815 14.9742 16.281 14.1271C16.0832 13.7087 15.8132 13.2437 15.434 12.8558C15.0515 12.4645 14.3998 11.9998 13.4998 11.9998C12.5999 11.9998 11.9482 12.4645 11.5657 12.8558C11.1865 13.2437 10.9165 13.7087 10.7187 14.1271C10.3484 14.9103 10.0572 15.908 9.82624 16.9998H7L11 20.9998L14.5 16.9998H11.875C12.312 15.1294 12.8795 13.9998 13.4998 13.9998C14.6442 13.9998 15.609 17.8443 15.9058 23.0912C15.5422 23.0371 15.1668 22.9998 14.7936 22.9998L7 22.9998ZM20.6838 31.0511L17.752 32.0284C17.9123 30.334 17.9999 28.4597 17.9999 26.4998C17.9999 26.1729 17.9974 25.8483 17.9926 25.5266C19.1193 25.7044 20.5513 25.7687 21.6761 24.7366C21.8356 24.5902 21.9905 24.4463 22.1419 24.3056C23.1972 23.3247 24.0826 22.5017 25.2 22.1073L31.3328 19.9428C31.7326 19.8017 32 19.4238 32 18.9998V16.9029C32 16.2217 32.2318 15.5608 32.6574 15.0288L35.047 12.0418C35.1402 12.3354 35.0965 12.667 34.9028 12.9333L34.1913 13.9116C33.8664 14.3583 33.9652 14.9837 34.4118 15.3085C34.8585 15.6334 35.4839 15.5346 35.8087 15.088L38.615 11.2294C38.9197 10.8104 39.4881 10.6982 39.9252 10.9523L39.0774 16.8872L34.4855 19.6423C34.3663 19.7139 34.2632 19.8095 34.183 19.9231L30.2316 25.5209C29.0162 27.2428 27.3095 28.5202 25.3147 29.203C24.8415 29.365 24.3804 29.5348 24.0277 29.7069C23.8561 29.7907 23.6582 29.8995 23.4889 30.0386C23.3682 30.1378 23 30.46 23 30.9998H21C20.8925 30.9998 20.7857 31.0171 20.6838 31.0511Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );