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="M11 35.9998L11 11.9998C11 10.7368 11.7911 9.60901 12.9787 9.17903C14.1663 8.74905 15.4961 9.10898 16.3047 10.0793L31 27.7137L31 11.9998C31 10.343 32.3431 8.99984 34 8.99984C35.6569 8.99984 37 10.343 37 11.9998L37 35.9998C37 37.2629 36.2089 38.3907 35.0213 38.8207C33.8337 39.2506 32.5039 38.8907 31.6953 37.9204L17 20.286L17 35.9998C17 37.6567 15.6569 38.9998 14 38.9998C12.3431 38.9998 11 37.6567 11 35.9998ZM13 11.9998L13 35.9998C13 36.5521 13.4477 36.9998 14 36.9998C14.5523 36.9998 15 36.5521 15 35.9998L15 17.5239C15 17.1029 15.2637 16.727 15.6596 16.5837C16.0554 16.4403 16.4987 16.5603 16.7682 16.8838L33.2318 36.64C33.5013 36.9635 33.9445 37.0834 34.3404 36.9401C34.7363 36.7968 35 36.4209 35 35.9998L35 11.9998C35 11.4476 34.5523 10.9998 34 10.9998C33.4477 10.9998 33 11.4476 33 11.9998L33 30.4757C33 30.8968 32.7363 31.2727 32.3404 31.416C31.9445 31.5593 31.5013 31.4394 31.2318 31.1159L14.7682 11.3597L15.5364 10.7195L14.7682 11.3597C14.4987 11.0362 14.0554 10.9162 13.6596 11.0596C13.2637 11.2029 13 11.5788 13 11.9998Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );