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="M15 12C15 10.3431 16.3432 9 18 9L30 9C31.6569 9 33 10.3431 33 12C33 13.6569 31.6569 15 30 15C31.6569 15 33 16.3431 33 18C33 19.6569 31.6569 21 30 21H28.4876C27.6088 23.4865 25.6696 25.4706 23.212 26.4097L28.4962 34.3359C29.4152 35.7145 29.0427 37.5771 27.6641 38.4962C26.2855 39.4152 24.4229 39.0427 23.5039 37.6641L15.5039 25.6641C14.8901 24.7435 14.8329 23.5599 15.355 22.5844C15.877 21.609 16.8936 21 18 21C16.3432 21 15 19.6569 15 18C15 16.3431 16.3432 15 18 15C16.3432 15 15 13.6569 15 12ZM18 11C17.4477 11 17 11.4477 17 12C17 12.5523 17.4477 13 18 13L20 13C21.852 13 23.4675 14.0074 24.3305 15.4993C24.5094 15.8087 24.5097 16.19 24.3311 16.4996C24.1525 16.8092 23.8223 17 23.4649 17H18C17.4477 17 17 17.4477 17 18C17 18.5523 17.4477 19 18 19H23.4649C23.8223 19 24.1525 19.1908 24.3311 19.5004C24.5097 19.81 24.5094 20.1913 24.3305 20.5007C23.4675 21.9926 21.852 23 20 23H18C17.6312 23 17.2923 23.203 17.1183 23.5281C16.9443 23.8533 16.9634 24.2478 17.168 24.5547L25.168 36.5547C25.4743 37.0142 26.0952 37.1384 26.5547 36.8321C27.0142 36.5257 27.1384 35.9048 26.8321 35.4453L20.7947 26.3892C20.6102 26.1125 20.5754 25.7623 20.7016 25.4547C20.8279 25.1471 21.0988 24.9224 21.4244 24.8552C24.0364 24.3156 26.1189 22.3173 26.7795 19.7507C26.8933 19.3089 27.2917 19 27.748 19H30C30.5523 19 31 18.5523 31 18C31 17.4477 30.5523 17 30 17H27.748C27.2917 17 26.8933 16.6911 26.7795 16.2493C26.6199 15.6292 26.3774 15.0422 26.0641 14.5007C25.8852 14.1913 25.8849 13.81 26.0635 13.5004C26.2421 13.1908 26.5723 13 26.9297 13H30C30.5523 13 31 12.5523 31 12C31 11.4477 30.5523 11 30 11L18 11Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );