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="M6 41C6 41.5523 6.44772 42 7 42H41V40H8V35.3588L14.3519 27.6458C14.8545 27.8733 15.4124 28 16 28C17.3878 28 18.6106 27.2932 19.3279 26.22L24.0035 28.1681C24.0916 30.2993 25.8472 32 28 32C30.2091 32 32 30.2091 32 28C32 27.2166 31.7748 26.4858 31.3856 25.8688L36.3608 19.6498C36.861 19.8748 37.4159 20 38 20C40.2091 20 42 18.2091 42 16C42 13.7909 40.2091 12 38 12C35.7909 12 34 13.7909 34 16C34 16.9004 34.2975 17.7313 34.7995 18.3998L29.9251 24.4929C29.354 24.1787 28.6979 24 28 24C26.4456 24 25.0983 24.8866 24.4362 26.1817L19.9868 24.3278C19.9955 24.2197 20 24.1104 20 24C20 21.7909 18.2091 20 16 20C13.7909 20 12 21.7909 12 24C12 24.8968 12.2951 25.7247 12.7936 26.3919L8 32.2127V7H6V41ZM18 24C18 25.1046 17.1046 26 16 26C14.8954 26 14 25.1046 14 24C14 22.8954 14.8954 22 16 22C17.1046 22 18 22.8954 18 24ZM28 30C29.1046 30 30 29.1046 30 28C30 26.8954 29.1046 26 28 26C26.8954 26 26 26.8954 26 28C26 29.1046 26.8954 30 28 30ZM40 16C40 17.1046 39.1046 18 38 18C36.8954 18 36 17.1046 36 16C36 14.8954 36.8954 14 38 14C39.1046 14 40 14.8954 40 16Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );