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="M31.6954 10.0795C32.7561 8.80669 34.6478 8.63472 35.9206 9.69541C37.1935 10.7561 37.3654 12.6478 36.3047 13.9206L35.5365 13.2804L36.3047 13.9206L27.0001 25.0862V36.0001C27.0001 37.6569 25.6569 39.0001 24.0001 39.0001C22.3432 39.0001 21.0001 37.6569 21.0001 36.0001V25.0862L11.6954 13.9206C10.6347 12.6478 10.8067 10.7561 12.0795 9.69541L12.7197 10.4636L12.0795 9.69541C13.3524 8.63472 15.244 8.80669 16.3047 10.0795L24.0001 19.3139L31.6954 10.0795ZM34.6403 11.2319C34.216 10.8783 33.5854 10.9356 33.2319 11.3599L24.7683 21.5162C24.5783 21.7442 24.2969 21.876 24.0001 21.876C23.7033 21.876 23.4219 21.7442 23.2319 21.5162L14.7683 11.3599C14.4147 10.9356 13.7842 10.8783 13.3599 11.2319C12.9356 11.5854 12.8783 12.216 13.2319 12.6403L22.7683 24.084C22.9181 24.2637 23.0001 24.4902 23.0001 24.7242V36.0001C23.0001 36.5524 23.4478 37.0001 24.0001 37.0001C24.5524 37.0001 25.0001 36.5524 25.0001 36.0001V24.7242C25.0001 24.4902 25.0821 24.2637 25.2319 24.084L34.7683 12.6403C35.1219 12.216 35.0645 11.5854 34.6403 11.2319Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );