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 36L11 12C11 10.7369 11.7911 9.60916 12.9787 9.17918C14.1663 8.7492 15.4961 9.10913 16.3047 10.0794L24 19.3138L31.6953 10.0794C32.5039 9.10913 33.8337 8.7492 35.0213 9.17918C36.2089 9.60916 37 10.7369 37 12L37 36C37 37.6569 35.6569 39 34 39C32.3431 39 31 37.6569 31 36L31 20.2861L26.3047 25.9205C25.7347 26.6045 24.8903 27 24 27C23.1097 27 22.2653 26.6045 21.6953 25.9205L17 20.2861L17 36C17 37.6569 15.6569 39 14 39C12.3431 39 11 37.6569 11 36ZM13 12L13 36C13 36.5523 13.4477 37 14 37C14.5523 37 15 36.5523 15 36L15 17.5241C15 17.1031 15.2637 16.7271 15.6596 16.5838C16.0554 16.4405 16.4987 16.5605 16.7682 16.8839L23.2318 24.6402C23.4218 24.8682 23.7032 25 24 25C24.2968 25 24.5782 24.8682 24.7682 24.6402L31.2318 16.8839C31.5013 16.5605 31.9445 16.4405 32.3404 16.5838C32.7363 16.7272 33 17.1031 33 17.5241L33 36C33 36.5523 33.4477 37 34 37C34.5523 37 35 36.5523 35 36L35 12C35 11.579 34.7363 11.203 34.3404 11.0597C33.9445 10.9164 33.5013 11.0364 33.2318 11.3598L24.7682 21.5161C24.5782 21.7441 24.2968 21.8759 24 21.8759C23.7032 21.8759 23.4218 21.7441 23.2318 21.5161L14.7682 11.3598C14.4987 11.0364 14.0554 10.9164 13.6596 11.0597C13.2637 11.203 13 11.579 13 12Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );