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 d="M16 18C16 11.9249 20.9249 7 27 7C33.0751 7 38 11.9249 38 18C38 21.8069 36.067 25.1627 33.1242 27.139C30.6282 28.8153 28 31.4539 28 34.9113V35C28 38.3137 25.3137 41 22 41C18.6863 41 16 38.3137 16 35V33H14V35C14 39.4183 17.5817 43 22 43C26.4183 43 30 39.4183 30 35V34.9113C30 32.5075 31.8696 30.3908 34.2393 28.7993C37.7115 26.4674 40 22.5012 40 18C40 10.8203 34.1797 5 27 5C19.8203 5 14 10.8203 14 18H16Z" fill="black"/>
<path d="M28.6341 11.1934C27.0134 10.8043 25.3071 11.0063 23.822 11.763L24.73 13.545C25.7908 13.0045 27.0096 12.8602 28.1672 13.1382C29.3248 13.4161 30.3453 14.0979 31.045 15.0611C31.7448 16.0242 32.0779 17.2055 31.9845 18.3923C31.8911 19.5792 31.3773 20.6937 30.5355 21.5355L31.9497 22.9498C33.1283 21.7712 33.8476 20.2108 33.9784 18.5492C34.1091 16.8876 33.6427 15.2339 32.6631 13.8855C31.6834 12.5371 30.2547 11.5825 28.6341 11.1934Z" fill="black"/>
<path d="M13.5859 25.0001L8.29285 19.707L9.70706 18.2928L15.0001 23.5858L20.293 18.293L21.7072 19.7072L16.4143 25.0001L21.707 30.2928L20.2928 31.707L15.0001 26.4143L9.7072 31.7072L8.29298 30.293L13.5859 25.0001Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );