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="M22.0905 17.803C13.5442 17.0268 8 11.1689 8 6H6C6 10.7865 9.59068 15.5042 15.1186 18.0199C13.9433 18.0801 12.9699 18.6573 12.241 19.3701C11.4797 20.1147 10.8857 21.0941 10.4301 22.1476C9.51599 24.2612 9 27.0416 9 30.0074C9 33.3891 10.5741 36.3381 12.3854 38.395C13.2994 39.4329 14.3195 40.298 15.3253 40.9175C16.2781 41.5044 17.4272 41.9999 18.5628 41.9999C19.9277 41.9999 20.9503 41.2971 21.5962 40.3621C22.175 39.5241 22.4693 38.492 22.6434 37.5469C22.9677 35.7856 22.9972 33.5585 22.9998 31.5L23 17.8856L22.0905 17.803ZM15.3731 20.0147C16.9813 20.0145 21 20.0139 21 21.9924V30.9999C21 35.4924 20.9496 39.9999 18.5628 39.9999C16.1761 39.9999 11 35.5262 11 30.0074C11 24.4886 12.9349 20.0147 15.3216 20.0147L15.3731 20.0147Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M40 6C40 11.1689 34.4558 17.0268 25.9095 17.803L25 17.8856V31.5C25.0026 33.5585 25.0323 35.7856 25.3566 37.5469C25.5307 38.492 25.825 39.5241 26.4038 40.3621C27.0497 41.2971 28.0723 41.9999 29.4372 41.9999C30.5728 41.9999 31.7219 41.5044 32.6747 40.9175C33.6805 40.298 34.7006 39.4329 35.6146 38.395C37.4259 36.3381 39 33.3891 39 30.0074C39 27.0416 38.484 24.2612 37.5699 22.1476C37.1143 21.0941 36.5203 20.1147 35.759 19.3701C35.0301 18.6573 34.0567 18.0801 32.8814 18.0199C38.4093 15.5042 42 10.7865 42 6H40ZM27 21.9924V30.9999C27 35.4924 27.0504 39.9999 29.4372 39.9999C29.9185 39.9999 30.5132 39.818 31.156 39.4823C30.5207 39.3086 29.9279 38.8991 29.5538 38.3132C28.927 37.3314 29.1311 36.1934 29.9849 35.6347C29.8743 35.0941 29.8446 34.5485 29.9017 34.0153C28.9839 33.2891 28.6626 32.1024 29.1952 31.2305C29.7278 30.3586 30.9303 30.1028 31.9954 30.5878C32.4437 30.2937 32.9426 30.0711 33.4741 29.9227C33.5815 28.908 34.5008 28.207 35.6605 28.3165C36.1385 28.3616 36.5893 28.538 36.9689 28.803C36.7117 23.8521 34.8889 20.0147 32.6784 20.0147L32.6269 20.0147C31.0187 20.0145 27 20.0139 27 21.9924Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );