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="M25.4999 15.0002C27.9852 15.0002 29.9999 12.9855 29.9999 10.5002C29.9999 8.01496 27.9852 6.00024 25.4999 6.00024C23.0146 6.00024 20.9999 8.01496 20.9999 10.5002C20.9999 12.9855 23.0146 15.0002 25.4999 15.0002ZM30.1171 18.0535C30.1171 18.6353 29.6432 19.1069 29.0585 19.1069C28.4739 19.1069 28 18.6353 28 18.0535C28 17.4717 28.4739 17.0001 29.0585 17.0001C29.6432 17.0001 30.1171 17.4717 30.1171 18.0535ZM42 39.5001C42 40.8808 38.6421 42.0001 34.5 42.0001C30.3578 42.0001 27 40.8808 27 39.5001C27 38.1194 30.3578 37.0001 34.5 37.0001C34.6878 37.0001 34.8741 37.0024 35.0585 37.0069C35.0204 36.8712 35 36.7281 35 36.5802C35 35.7075 35.7109 35.0001 36.5878 35.0001C37.4647 35.0001 38.1757 35.7075 38.1757 36.5802C38.1757 36.8353 38.1149 37.0763 38.007 37.2897C40.382 37.7092 42 38.5417 42 39.5001ZM31.5878 25.1603C32.4647 25.1603 33.1757 24.4529 33.1757 23.5802C33.1757 22.7075 32.4647 22.0001 31.5878 22.0001C30.7109 22.0001 30 22.7075 30 23.5802C30 24.4529 30.7109 25.1603 31.5878 25.1603ZM37.1171 29.0535C37.1171 29.6353 36.6432 30.1069 36.0585 30.1069C35.4739 30.1069 35 29.6353 35 29.0535C35 28.4717 35.4739 28.0001 36.0585 28.0001C36.6432 28.0001 37.1171 28.4717 37.1171 29.0535ZM31.0585 33.1069C31.6432 33.1069 32.1171 32.6353 32.1171 32.0535C32.1171 31.4717 31.6432 31.0001 31.0585 31.0001C30.4739 31.0001 30 31.4717 30 32.0535C30 32.6353 30.4739 33.1069 31.0585 33.1069ZM12.348 25.3809C13.0064 26.1254 13.6781 26.8129 14.2129 27.3391C14.5179 27.6392 14.7745 27.883 14.9534 28.0504C15.0427 28.1341 15.1125 28.1985 15.1589 28.2411L15.2105 28.2882L15.2223 28.2989L15.2243 28.3007C15.6138 28.6519 15.8501 29.1425 15.8816 29.6661L16.4964 39.8801C16.5628 40.9826 15.7228 41.9303 14.6202 41.9966C13.5177 42.063 12.57 41.223 12.5037 40.1204L11.9368 30.7032C11.7825 30.556 11.6039 30.3836 11.4075 30.1904C10.7469 29.5404 9.86835 28.6388 9.0231 27.6536C8.19358 26.6868 7.32407 25.557 6.74302 24.457C6.45324 23.9085 6.18588 23.2765 6.06629 22.6129C5.94618 21.9465 5.94817 21.079 6.42326 20.2561C9.12062 15.5841 11.8137 13.3573 14.2514 12.4488C15.4663 11.996 16.5371 11.9027 17.3894 11.9411C18.0577 11.9713 19.0261 12.1564 18.8534 12.1344C19.8439 12.2604 20.3394 12.9717 20.5213 13.3257C20.7055 13.6841 20.7731 14.0378 20.8046 14.2517C20.8717 14.7078 20.8664 15.2265 20.8431 15.6894C20.7947 16.6526 20.6379 17.8675 20.4629 19.0121C20.2856 20.1719 20.0798 21.3218 19.9192 22.1776C19.8904 22.331 19.863 22.4752 19.8375 22.6086L23.5357 26.6514C24.2812 27.4664 24.2249 28.7315 23.4099 29.477C22.5949 30.2226 21.3298 30.1662 20.5843 29.3512L16.2044 24.5633C15.7719 24.0905 15.5921 23.4391 15.7209 22.8114L15.7255 22.7889L15.74 22.7172C15.7528 22.6537 15.7716 22.5598 15.7954 22.4396C15.8429 22.1992 15.91 21.8544 15.9878 21.4399C16.0452 21.1341 16.1081 20.7917 16.1731 20.4263C14.69 21.7194 13.7285 23.0803 12.7037 24.788L12.348 25.3809Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );