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="M17.7085 38.5131C18.4858 38.2187 19 37.4741 19 36.6428V34.2439L31.9859 30.3481C32.5055 31.974 33.9785 33.1465 35.7144 33.1465C37.8841 33.1465 39.643 31.3149 39.643 29.0556C39.643 28.8415 39.6272 28.6314 39.5968 28.4262C41.0313 27.5845 42 25.9833 42 24.1465C42 22.3097 41.0313 20.7085 39.5968 19.8667C39.6272 19.6616 39.643 19.4514 39.643 19.2374C39.643 16.978 37.8841 15.1465 35.7144 15.1465C34.0743 15.1465 32.6689 16.1931 32.0806 17.68L19 13.7558V11.3572C19 10.526 18.4858 9.78138 17.7085 9.48692L9.38557 6.33432C7.74994 5.71476 6 6.92318 6 8.67222V39.3278C6 41.0769 7.74994 42.2853 9.38557 41.6657L17.7085 38.5131ZM8.67711 8.20464C8.34999 8.08072 8 8.32241 8 8.67222V39.3278C8 39.6776 8.34999 39.9193 8.67711 39.7954L17 36.6428V34.8439L13.6131 35.8599C13.4132 35.9522 13.2085 36 13 36C10.7909 36 9 30.6274 9 24C9 17.3726 10.7909 12 13 12C13.2077 12 13.4117 12.0475 13.6108 12.139L17 13.1558L17 11.3572L8.67711 8.20464ZM13.9311 31.8528C13.6132 32.8063 13.2784 33.4413 13 33.8013C12.7216 33.4413 12.3868 32.8063 12.0689 31.8528C11.4297 29.9351 11 27.1586 11 24C11 20.8414 11.4297 18.0649 12.0689 16.1472C12.3868 15.1937 12.7216 14.5587 13 14.1987C13.2784 14.5587 13.6132 15.1937 13.9311 16.1472C14.5703 18.0649 15 20.8414 15 24C15 27.1586 14.5703 29.9351 13.9311 31.8528ZM31.581 27.9577C31.2266 27.0576 31.0001 25.6846 31.0001 24.1465C31.0001 22.415 31.2871 20.8929 31.7205 20.0189C30.35 20.2036 29 21.7258 29 24C29 26.197 30.2598 27.6922 31.581 27.9577ZM15.5748 14.8163L29.3012 18.9342C27.8717 20.0371 27 21.9784 27 24C27 26.0214 27.8716 27.9626 29.3008 29.0655L15.575 33.1833C16.4463 30.982 17 27.685 17 24C17 20.3148 16.4463 17.0175 15.5748 14.8163ZM33.5464 20.8439L33.9026 20.2429L33.8072 19.5509C33.7932 19.4496 33.7858 19.345 33.7858 19.2374C33.7858 18.0055 34.7248 17.1465 35.7144 17.1465C36.704 17.1465 37.643 18.0055 37.643 19.2374C37.643 19.353 37.6345 19.4651 37.6184 19.5734L37.4204 20.9086L38.5846 21.5917C39.4086 22.0752 40 23.0208 40 24.1465C40 25.2721 39.4086 26.2177 38.5846 26.7013L37.4204 27.3844L37.6184 28.7196C37.6345 28.8279 37.643 28.94 37.643 29.0556C37.643 30.2874 36.704 31.1465 35.7144 31.1465C34.7248 31.1465 33.7858 30.2874 33.7858 29.0556C33.7858 28.948 33.7932 28.8434 33.8072 28.7421L33.9026 28.05L33.5464 27.449C33.3288 27.0819 33.0001 25.8912 33.0001 24.1465C33.0001 22.4018 33.3288 21.2111 33.5464 20.8439Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );