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="M22.0621 25.6021L11.3291 5.4162C11.0698 4.92856 11.2549 4.32307 11.7426 4.06378C12.2302 3.8045 12.8357 3.98962 13.095 4.47726L23.828 24.6632L25.3504 23.8538C27.3009 22.8167 29.7229 23.5571 30.7601 25.5077L31.408 26.7263L38.277 36.7808L24.0282 44.357L19.5334 33.039L18.886 31.8212C17.8489 29.8707 18.5894 27.4487 20.5399 26.4116L22.0621 25.6021ZM21.4789 28.1775L26.2893 25.6197C27.2646 25.1011 28.4756 25.4714 28.9942 26.4466L29.6416 27.6644L21.2994 32.1L20.6519 30.8823C20.1333 29.907 20.5036 28.696 21.4789 28.1775ZM22.309 34.6095L25.0622 41.5421L26.8965 40.5668L24.7315 36.3515L26.5105 35.4378L28.6625 39.6277L35.3651 36.0639L31.1573 29.9048L22.309 34.6095Z" fill="black"/>
<path d="M16.3603 35.2314C16.7846 34.8783 17.4148 34.9358 17.7682 35.3599C18.1218 35.7842 18.0645 36.4147 17.6402 36.7683L17.639 36.7693L17.6375 36.7705L17.634 36.7734L17.6241 36.7815L17.5938 36.8058C17.5689 36.8256 17.5346 36.8523 17.4912 36.885C17.4045 36.9503 17.2811 37.0395 17.1235 37.1446C16.8086 37.3545 16.3544 37.6294 15.7799 37.9029C14.6334 38.4489 12.9856 39.0001 11 39.0001C10.4477 39.0001 10 38.5524 10 38.0001C10 37.4478 10.4477 37.0001 11 37.0001C12.6144 37.0001 13.9666 36.5513 14.9201 36.0972C15.3956 35.8708 15.7664 35.6456 16.0141 35.4805C16.1377 35.3981 16.2299 35.3311 16.2885 35.287C16.3177 35.265 16.3385 35.2488 16.3505 35.2392L16.3619 35.2301L16.3603 35.2314Z" fill="black"/>
<path d="M19.5547 41.8321C20.0142 41.5258 20.1384 40.9049 19.8321 40.4454C19.5258 39.986 18.9048 39.862 18.4453 40.168L18.4427 40.1697L18.4234 40.1822C18.4051 40.1941 18.376 40.2126 18.3369 40.237C18.2587 40.2857 18.1405 40.3573 17.9882 40.4443C17.683 40.6187 17.2446 40.8526 16.7189 41.0863C15.6498 41.5614 14.2984 42.0001 13 42.0001C12.4477 42.0001 12 42.4478 12 43.0001C12 43.5524 12.4477 44.0001 13 44.0001C14.7016 44.0001 16.3502 43.4388 17.5311 42.9139C18.1304 42.6476 18.6295 42.3814 18.9805 42.1808C19.1564 42.0803 19.296 41.9957 19.3935 41.9351C19.4423 41.9047 19.4806 41.8803 19.5077 41.8628L19.5399 41.8419L19.5495 41.8356L19.5547 41.8321Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );