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="M19.8666 8.40322C19.6615 8.3728 19.4513 8.35701 19.2373 8.35701C16.9779 8.35701 15.1464 10.1159 15.1464 12.2856C15.1464 13.9258 16.1931 15.3313 17.6801 15.9195L12.1396 34.388C12.0477 34.5875 12 34.7919 12 35C12 37.2091 17.3726 39 24 39C30.6274 39 36 37.2091 36 35C36 34.7919 35.9523 34.5875 35.8604 34.388L30.3482 16.014C31.974 15.4943 33.1464 14.0214 33.1464 12.2856C33.1464 10.1159 31.3148 8.35701 29.0554 8.35701C28.8414 8.35701 28.6312 8.3728 28.4261 8.40322C27.5843 6.96875 25.9831 6 24.1464 6C22.3096 6 20.7084 6.96874 19.8666 8.40322ZM20.2428 14.0974L20.8438 14.4536C21.211 14.6712 22.4017 14.9999 24.1464 14.9999C25.891 14.9999 27.0818 14.6712 27.4489 14.4536L28.0499 14.0974L28.742 14.1928C28.8433 14.2068 28.9478 14.2142 29.0554 14.2142C30.2873 14.2142 31.1464 13.2752 31.1464 12.2856C31.1464 11.296 30.2873 10.357 29.0554 10.357C28.9399 10.357 28.8278 10.3655 28.7194 10.3816L27.3843 10.5796L26.7012 9.41544C26.2176 8.59142 25.272 8 24.1464 8C23.0207 8 22.0751 8.59142 21.5916 9.41543L20.9084 10.5796L19.5733 10.3816C19.465 10.3655 19.3529 10.357 19.2373 10.357C18.0054 10.357 17.1464 11.296 17.1464 12.2856C17.1464 13.2752 18.0054 14.2142 19.2373 14.2142C19.3449 14.2142 19.4495 14.2068 19.5507 14.1928L20.2428 14.0974ZM24 19C21.7258 19 20.2036 17.6501 20.0189 16.2795C20.8929 16.713 22.415 16.9999 24.1464 16.9999C25.6846 16.9999 27.0576 16.7734 27.9577 16.4189C27.6922 17.7401 26.197 19 24 19ZM14.8165 32.4251C17.0177 31.5537 20.3149 31 24 31C27.6851 31 30.9823 31.5537 33.1835 32.4251L29.0657 18.699C27.9627 20.1284 26.0215 21 24 21C21.9785 21 20.0373 20.1284 18.9343 18.699L14.8165 32.4251ZM31.8528 34.0689C32.8063 34.3868 33.4413 34.7216 33.8013 35C33.4413 35.2784 32.8063 35.6132 31.8528 35.9311C29.9351 36.5703 27.1586 37 24 37C20.8414 37 18.0649 36.5703 16.1472 35.9311C15.1937 35.6132 14.5587 35.2784 14.1987 35C14.5587 34.7216 15.1937 34.3868 16.1472 34.0689C18.0649 33.4297 20.8414 33 24 33C27.1586 33 29.9351 33.4297 31.8528 34.0689Z" fill="black"/>
<path d="M39 37C39 37.5523 38.5523 38 38 38C37.4477 38 37 37.5523 37 37C37 36.4477 37.4477 36 38 36C38.5523 36 39 36.4477 39 37Z" fill="black"/>
<path d="M39 31C39.5523 31 40 30.5523 40 30C40 29.4477 39.5523 29 39 29C38.4477 29 38 29.4477 38 30C38 30.5523 38.4477 31 39 31Z" fill="black"/>
<path d="M27 41C27 41.5523 26.5523 42 26 42C25.4477 42 25 41.5523 25 41C25 40.4477 25.4477 40 26 40C26.5523 40 27 40.4477 27 41Z" fill="black"/>
<path d="M41 39C41 39.5523 40.5523 40 40 40C39.4477 40 39 39.5523 39 39C39 38.4477 39.4477 38 40 38C40.5523 38 41 38.4477 41 39Z" fill="black"/>
<path d="M12 40C11.4477 40 11 39.5523 11 39C11 38.4477 11.4477 38 12 38C12.5523 38 13 38.4477 13 39C13 39.5523 12.5523 40 12 40Z" fill="black"/>
<path d="M7 39C7 39.5523 7.44772 40 8 40C8.55228 40 9 39.5523 9 39C9 38.4477 8.55228 38 8 38C7.44772 38 7 38.4477 7 39Z" fill="black"/>
<path d="M41 33C41.5523 33 42 32.5523 42 32C42 31.4477 41.5523 31 41 31C40.4477 31 40 31.4477 40 32C40 32.5523 40.4477 33 41 33Z" fill="black"/>
<path d="M8 30C8 30.5523 8.44772 31 9 31C9.55228 31 10 30.5523 10 30C10 29.4477 9.55228 29 9 29C8.44772 29 8 29.4477 8 30Z" fill="black"/>
<path d="M34 42C34.5523 42 35 41.5523 35 41C35 40.4477 34.5523 40 34 40C33.4477 40 33 40.4477 33 41C33 41.5523 33.4477 42 34 42Z" fill="black"/>
<path d="M17 41C17 41.5523 17.4477 42 18 42C18.5523 42 19 41.5523 19 41C19 40.4477 18.5523 40 18 40C17.4477 40 17 40.4477 17 41Z" fill="black"/>
<path d="M38 42C38.5523 42 39 41.5523 39 41C39 40.4477 38.5523 40 38 40C37.4477 40 37 40.4477 37 41C37 41.5523 37.4477 42 38 42Z" fill="black"/>
<path d="M13 41C13 41.5523 13.4477 42 14 42C14.5523 42 15 41.5523 15 41C15 40.4477 14.5523 40 14 40C13.4477 40 13 40.4477 13 41Z" fill="black"/>
<path d="M10 42C9.44772 42 9 41.5523 9 41C9 40.4477 9.44772 40 10 40C10.5523 40 11 40.4477 11 41C11 41.5523 10.5523 42 10 42Z" fill="black"/>
<path d="M42 36C42 36.5523 41.5523 37 41 37C40.4477 37 40 36.5523 40 36C40 35.4477 40.4477 35 41 35C41.5523 35 42 35.4477 42 36Z" fill="black"/>
<path d="M10 38C9.44772 38 9 37.5523 9 37C9 36.4477 9.44772 36 10 36C10.5523 36 11 36.4477 11 37C11 37.5523 10.5523 38 10 38Z" fill="black"/>
<path d="M8 34C8 34.5523 8.44772 35 9 35C9.55228 35 10 34.5523 10 34C10 33.4477 9.55228 33 9 33C8.44772 33 8 33.4477 8 34Z" fill="black"/>
<path d="M7 33C6.44772 33 6 32.5523 6 32C6 31.4477 6.44772 31 7 31C7.55228 31 8 31.4477 8 32C8 32.5523 7.55228 33 7 33Z" fill="black"/>
<path d="M6 36C6 36.5523 6.44772 37 7 37C7.55228 37 8 36.5523 8 36C8 35.4477 7.55228 35 7 35C6.44772 35 6 35.4477 6 36Z" fill="black"/>
<path d="M36 40C36.5523 40 37 39.5523 37 39C37 38.4477 36.5523 38 36 38C35.4477 38 35 38.4477 35 39C35 39.5523 35.4477 40 36 40Z" fill="black"/>
<path d="M31 41C31 41.5523 30.5523 42 30 42C29.4477 42 29 41.5523 29 41C29 40.4477 29.4477 40 30 40C30.5523 40 31 40.4477 31 41Z" fill="black"/>
<path d="M22 42C21.4477 42 21 41.5523 21 41C21 40.4477 21.4477 40 22 40C22.5523 40 23 40.4477 23 41C23 41.5523 22.5523 42 22 42Z" fill="black"/>
<path d="M40 34C40 34.5523 39.5523 35 39 35C38.4477 35 38 34.5523 38 34C38 33.4477 38.4477 33 39 33C39.5523 33 40 33.4477 40 34Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );