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="M12.5 6C11.3882 10.0166 9.95743 11.3892 6 12.5C9.95743 13.6108 11.3882 14.9833 12.5 19C13.6118 14.9833 15.0426 13.6108 19 12.5C15.0426 11.3892 13.6118 10.0166 12.5 6Z" fill="black"/>
<path d="M12.5 23C11.3882 27.0166 9.95743 28.3892 6 29.5C9.95743 30.6108 11.3882 31.9834 12.5 36C13.6118 31.9834 15.0426 30.6108 19 29.5C15.0426 28.3892 13.6118 27.0166 12.5 23Z" fill="black"/>
<path d="M23 12.5C26.9574 11.3892 28.3882 10.0166 29.5 6C30.6118 10.0166 32.0426 11.3892 36 12.5C32.0426 13.6108 30.6118 14.9833 29.5 19C28.3882 14.9833 26.9574 13.6108 23 12.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M35.7992 41.4559L35.5697 41.2264L35.5564 41.2132L17.4144 23.0711C16.6334 22.2901 16.6334 21.0238 17.4144 20.2427L20.2428 17.4143C21.0239 16.6332 22.2902 16.6332 23.0713 17.4143L41.456 35.7991C42.2371 36.5801 42.2371 37.8464 41.456 38.6275L38.6276 41.4559C37.8466 42.237 36.5802 42.237 35.7992 41.4559ZM22.6161 25.4444L18.8286 21.6569L21.657 18.8285L25.4445 22.616L22.6161 25.4444Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );