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="M35.2929 15.7071L34 14.4142L31.9142 16.5L34.7071 19.2929L33.2929 20.7071L32 19.4142L26.1213 25.2929C25.166 26.2483 23.7265 26.4246 22.5925 25.8218L21.4142 27.0001L30.5858 27L33.5858 24H38C38.8885 24 39.6868 24.3863 40.2361 25H41C42.6569 25 44 26.3432 44 28V35C44 36.6569 42.6569 38 41 38L34 38C32.5195 38 31.2268 37.1957 30.5352 36.0001H15.4853C13.6288 36.0001 11.8483 35.2626 10.5355 33.9499L7.47008 30.8844L6.22336 32.1905C5.84202 32.59 5.20902 32.6047 4.80952 32.2234C4.41003 31.842 4.39531 31.2091 4.77664 30.8096L6.05548 29.4698L4 27.4143V12.4771C4 11.0426 5.82019 10.4265 6.69154 11.5659L14.0101 21.1364L15.2766 19.8096C15.658 19.4101 16.291 19.3953 16.6905 19.7767C17.09 20.158 17.1047 20.791 16.7234 21.1905L15.2399 22.7446L18.194 26.6076C18.3114 26.7611 18.469 26.8752 18.6461 26.9398L21.1783 24.4076C20.5754 23.2736 20.7517 21.8341 21.7071 20.8787L27.5858 15L26.2929 13.7071L27.7071 12.2929L30.5 15.0858L32.5858 13L31.2929 11.7071L32.7071 10.2929L36.7071 14.2929L35.2929 15.7071ZM17.1869 28.399C16.9699 28.2361 16.7738 28.0428 16.6053 27.8225L13.842 24.209L8.8514 29.4373L11.9497 32.5357C12.8874 33.4733 14.1592 34.0001 15.4853 34.0001L32 34C32 35.1046 32.8954 36 34 36L34.9996 36C34.3719 35.1644 34 34.1256 34 33V30.4H35.346C35.1251 29.9821 35 29.5057 35 29V28H37V29C37 29.5523 37.4477 30 38 30H39V27C39 26.4478 38.5523 26 38 26H34.4142L31.4142 29L19.4142 29.0001L17.4142 31.0001H14.5858L17.1869 28.399ZM29 16.4142L30.5858 18L28.5 20.0858L26.9142 18.5L29 16.4142ZM12.6122 22.6008L7.43681 28.0227L6 26.5859V13.954L12.6122 22.6008ZM42 35C42 35.5523 41.5523 36 41 36H39C37.3431 36 36 34.6569 36 33V31.2362C36.5308 31.7112 37.2316 32 38 32H41V27C41.5523 27 42 27.4478 42 28V35ZM25.5 19.9142L23.1213 22.2929C22.7308 22.6834 22.7308 23.3166 23.1213 23.7071L23.2929 23.8787C23.6834 24.2692 24.3166 24.2692 24.7071 23.8787L27.0858 21.5L25.5 19.9142Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );