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="M30 18V16H37V18H30Z" fill="black"/>
<path d="M30 13V15H37V13H30Z" fill="black"/>
<path d="M30 21H37V19H30V21Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 6C6.63577 6 6.27483 6.015 5.91778 6.04446C5.39914 6.08725 5 6.52067 5 7.04107V43C5 43.5523 5.44772 44 6 44H9C9.55228 44 10 43.5523 10 43V38.5165L10.1969 38.6009C10.2207 38.6295 10.2457 38.6576 10.2718 38.6854C10.7879 39.2337 11.5641 39.6642 12.3196 40.0009C13.1009 40.3489 13.9742 40.6453 14.7775 40.8843C15.5842 41.1243 16.3397 41.312 16.8923 41.4397C17.1692 41.5036 17.3966 41.5528 17.5556 41.5862C17.6352 41.6029 17.6978 41.6156 17.741 41.6243L17.7911 41.6343L17.8048 41.637L17.8106 41.6381L18.2899 41.7307L18.6577 41.4097C21.8166 38.653 23.7962 35.6985 24.3654 32.5146C24.9621 32.5651 25.2913 32.7387 25.4873 32.9152C25.7304 33.1339 25.913 33.4864 26.0161 34.0539C26.1203 34.6267 26.1254 35.315 26.0945 36.1014C26.085 36.3432 26.0717 36.6004 26.058 36.864C26.0297 37.4079 26 37.9797 26 38.5C26 39.4969 26.4101 40.3039 27.1425 40.8354C27.8228 41.329 28.6903 41.5206 29.5385 41.5583C31.2414 41.6341 33.3123 41.1094 35.0567 40.3138C35.9383 39.9117 36.7726 39.4244 37.4615 38.8759C38.1385 38.3369 38.7401 37.6872 39.0604 36.9411C39.4012 36.1469 39.4102 35.2564 38.8959 34.4259C38.4188 33.6557 37.5634 33.0554 36.4366 32.579C35.6888 32.2627 35.2425 31.8843 34.9609 31.4979C34.6768 31.1078 34.5135 30.6449 34.4331 30.0883C34.3512 29.521 34.3601 28.8931 34.3977 28.1885C34.4074 28.0077 34.4193 27.8185 34.4315 27.6242C34.4646 27.0977 34.5 26.534 34.5 26H36V24H41C41.5523 24 42 23.5523 42 23C42 22.4477 41.5523 22 41 22H40V8.5C40 7.11929 37.0899 6 33.5 6C29.9101 6 27 7.11929 27 8.5V22H26C25.4477 22 25 22.4477 25 23C25 23.5523 25.4477 24 26 24H31V26H32.5C32.5 26.467 32.4707 26.9333 32.4391 27.4358C32.426 27.6439 32.4125 27.8587 32.4006 28.0817C32.3616 28.8099 32.3422 29.6018 32.4537 30.3741C32.5667 31.1572 32.8185 31.9536 33.3444 32.6755C33.8731 33.4011 34.6319 33.9873 35.6577 34.421C36.6097 34.8236 37.0306 35.2127 37.1956 35.4791C37.3233 35.6852 37.34 35.8784 37.2225 36.1523C37.0843 36.4742 36.7614 36.8768 36.2158 37.3112C35.6821 37.7362 34.9957 38.1434 34.2267 38.4941C32.67 39.2042 30.92 39.6178 29.6274 39.5603C28.9777 39.5314 28.5538 39.3884 28.3171 39.2166C28.1325 39.0827 28 38.8934 28 38.5C28 38.0289 28.025 37.5526 28.0517 37.0436C28.0662 36.7668 28.0812 36.4803 28.093 36.1798C28.1246 35.3725 28.1297 34.4983 27.9839 33.6961C27.837 32.8886 27.5196 32.0536 26.8252 31.4286C26.2316 30.8943 25.4609 30.6012 24.5355 30.5221C24.5135 27.1795 22.9653 23.7912 20.043 20.3524L20 20.3019V19C20 11.8203 14.1797 6 7 6ZM17 21.5C17 22.3284 16.3284 23 15.5 23C14.6716 23 14 22.3284 14 21.5C14 20.6716 14.6716 20 15.5 20C16.3284 20 17 20.6716 17 21.5ZM37.3782 8.59892C37.6731 8.71232 37.8734 8.81908 38 8.90036V22H29V8.90036C29.1266 8.81908 29.3269 8.71232 29.6218 8.59892C30.5158 8.25506 31.8864 8 33.5 8C35.1136 8 36.4842 8.25506 37.3782 8.59892ZM18.9564 23.9686C19.1298 23.545 19.3032 23.1585 19.4621 22.8233C21.756 25.8665 22.6982 28.6542 22.5128 31.2336C22.3118 34.0297 20.7699 36.8012 17.7121 39.5742C17.6038 39.5505 17.4797 39.5227 17.3424 39.491C16.8169 39.3696 16.1036 39.1922 15.3478 38.9673C14.5885 38.7414 13.8056 38.4734 13.1336 38.174C12.5278 37.9041 12.0908 37.6424 11.8331 37.4154C11.8708 37.335 11.942 37.2112 12.0713 37.0382C12.4464 36.5366 13.0537 35.9447 13.8007 35.2169L14.0264 34.9968C14.8387 34.2039 15.7583 33.2881 16.4723 32.317C17.1775 31.358 17.7809 30.2158 17.7809 28.9688C17.7809 27.3034 18.3484 25.4543 18.9564 23.9686Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );