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="M23.0731 30.0748C22.6981 30.1171 22.3169 30.1389 21.9306 30.1389H16V35C16 35 15.1941 34.8368 14 34.3774C10.5863 33.064 4 29.3301 4 20.0694C4 14.5082 8.50824 10 14.0694 10H21.9306C26.7824 10 30.8328 13.4315 31.7871 18H35.9448C40.3938 18 44.0004 21.6066 44.0004 26.0556C44.0004 33.3346 38.1721 36.3455 35.0004 37.445C33.8148 37.856 33.0004 38 33.0004 38V34.1111H30.0559C27.3041 34.1111 24.8746 32.7313 23.4214 30.6258C23.2981 30.4472 23.1819 30.2634 23.0731 30.0748ZM14 28.1389V32.2144C13.144 31.8369 12.1551 31.3127 11.1722 30.6018C8.58293 28.7287 6 25.5539 6 20.0694C6 15.6128 9.61281 12 14.0694 12H21.9306C26.2287 12 29.742 15.3604 29.9864 19.5973C29.9819 19.6857 29.9761 19.7737 29.9693 19.8615C29.7527 22.6459 28.4034 25.1126 26.3819 26.8012C25.1059 27.6465 23.5757 28.1389 21.9306 28.1389H14ZM27.5748 28.4095C26.8897 28.9707 26.1419 29.458 25.3433 29.8594C26.4544 31.2338 28.1541 32.1111 30.0559 32.1111H35.0004V35.3122C35.7491 35.0157 36.5948 34.6156 37.4327 34.0866C39.7995 32.5924 42.0004 30.1645 42.0004 26.0556C42.0004 22.7112 39.2892 20 35.9448 20H31.9998C31.9999 20.0231 32 20.0463 32 20.0694C32 23.539 30.2452 26.5987 27.5748 28.4095Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );