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="M24.8162 4.41112C24.6278 4.15279 24.3273 4 24.0074 4C23.6876 4 23.387 4.15279 23.1986 4.41112C23.1833 4.43217 22.6586 5.15274 22.1334 6.07048C21.8711 6.5289 21.598 7.0549 21.3879 7.57994C21.1853 8.0862 21.0054 8.6781 21.0054 9.24256C21.0054 9.80689 21.1853 10.3986 21.3877 10.9048C21.5977 11.4297 21.8708 11.9556 22.1331 12.414C22.1769 12.4907 22.2208 12.566 22.2644 12.6396C22.0183 12.4819 21.7303 12.3044 21.4197 12.1269C20.961 11.8648 20.4348 11.592 19.9095 11.3821C19.403 11.1797 18.8108 11 18.2461 11C17.6813 11 17.089 11.1798 16.5824 11.3822C16.057 11.5922 15.5306 11.8651 15.0719 12.1273C14.1535 12.6522 13.4324 13.1765 13.4114 13.1918C13.1529 13.38 13 13.6804 13 14C13 14.3197 13.1529 14.62 13.4114 14.8083C13.4325 14.8236 14.1535 15.3479 15.0719 15.8727C15.5306 16.1349 16.057 16.4078 16.5824 16.6178C17.089 16.8202 17.6813 17 18.2461 17C18.8108 17 19.403 16.8203 19.9095 16.6179C20.4348 16.4081 20.961 16.1352 21.4197 15.8731C22.1759 15.441 22.7985 15.0091 23.0068 14.8613V19H18.0034C17.4507 19 17.0027 19.4477 17.0027 20C17.0027 20.5523 17.4507 21 18.0034 21H19.0041V25.3378C16.013 27.0669 14.0007 30.2986 14.0007 34C14.0007 39.5229 18.4809 44 24.0075 44C29.534 44 34.0142 39.5229 34.0142 34C34.0142 30.2986 32.0019 27.0669 29.0108 25.3378V21H30.0115C30.5642 21 31.0122 20.5523 31.0122 20C31.0122 19.4477 30.5642 19 30.0115 19H25.0081V14.8719C25.2299 15.0287 25.8409 15.4506 26.5797 15.8727C27.0384 16.1349 27.5648 16.4078 28.0902 16.6178C28.5968 16.8202 29.1891 17 29.7539 17C30.3186 17 30.9108 16.8203 31.4173 16.6179C31.9425 16.4081 32.4688 16.1352 32.9275 15.8731C33.8457 15.3484 34.5669 14.8241 34.5886 14.8083C34.8471 14.6201 35 14.3197 35 14C35 13.6804 34.8471 13.38 34.5886 13.1918C34.5669 13.176 33.8457 12.6517 32.9275 12.1269C32.4688 11.8648 31.9426 11.592 31.4173 11.3821C30.9108 11.1797 30.3186 11 29.7539 11C29.1891 11 28.5967 11.1798 28.0901 11.3822C27.5647 11.5922 27.0384 11.8651 26.5797 12.1273C26.2793 12.299 26.0001 12.4706 25.7595 12.6243C25.8001 12.5555 25.8409 12.4854 25.8818 12.414C26.1441 11.9556 26.4171 11.4297 26.6271 10.9048C26.8296 10.3987 27.0095 9.8069 27.0095 9.24256C27.0095 8.67809 26.8295 8.08618 26.627 7.57993C26.4169 7.05489 26.1438 6.52888 25.8814 6.07046C25.3562 5.15273 24.8315 4.43215 24.8162 4.41112ZM21.0054 21H23.0068L23.0068 31H16.5837C17.2553 29.3415 18.4678 27.9584 20.0062 27.069L21.0054 26.4914V21ZM31.4312 31C30.7596 29.3415 29.5471 27.9584 28.0087 27.069L27.0095 26.4914V21H25.0081L25.0081 31H31.4312Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );