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 d="M6.10881 24C6.55678 19.9303 8.36314 16.2691 11.065 13.4793L14.1214 16.5355L15.5356 15.1213L12.5348 12.1207C15.4086 9.74502 19.0332 8.24437 23 8.02729L23 13L25 13L25 8.02729C28.9668 8.24436 32.5915 9.74505 35.4653 12.1208L32.5858 14.9999L33.9999 16.4142L36.9351 13.4794C39.6369 16.2692 41.4432 19.9303 41.8912 24H37.6843V26H42C41.9975 30.3403 40.4579 34.3201 37.894 37.4269L34.4736 34.0067L33.0594 35.4209L36.5366 38.898L36.5239 38.9103L37.9152 40.3471C41.6663 36.7148 44 31.6236 44 25.9892C44 14.949 35.0452 6 24 6C12.9548 6 4 14.949 4 25.9892C4 31.4741 6.21161 36.4446 9.78969 40.0553L11.2103 38.6475C11.204 38.6412 11.1978 38.6349 11.1915 38.6285L14.1967 35.6232L12.7825 34.209L9.86416 37.1274C7.44565 34.0662 6.00246 30.2022 6 26H10.0527V24H6.10881Z" fill="black"/>
<path d="M21.5187 29.9093C21.1326 29.9834 20.7868 30.196 20.5463 30.507L18.9078 32.9363C18.7254 34.1504 18.8548 34.6334 19.5725 35.4169L22.2061 36.7014C22.5699 36.8506 22.9756 36.8617 23.3471 36.7329L36.0627 30.8606C37.9542 30.2044 37.4476 28.2437 35.4815 28.6212L21.5187 29.9093Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );