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="M24.8082 4.41112C24.62 4.15279 24.3196 4 24 4C23.6803 4 23.38 4.15279 23.1917 4.41112C23.1764 4.43217 22.6521 5.15274 22.1273 6.07048C21.8651 6.5289 21.5922 7.0549 21.3822 7.57994C21.1798 8.0862 21 8.6781 21 9.24256C21 9.80689 21.1797 10.3986 21.3821 10.9048C21.5919 11.4297 21.8648 11.9556 22.1269 12.414C22.1707 12.4907 22.2146 12.566 22.2581 12.6396C22.0122 12.4819 21.7244 12.3044 21.414 12.1269C20.9556 11.8648 20.4297 11.592 19.9048 11.3821C19.3987 11.1797 18.8069 11 18.2426 11C17.6781 11 17.0862 11.1798 16.5799 11.3822C16.0549 11.5922 15.5289 11.8651 15.0705 12.1273C14.1527 12.6522 13.4322 13.1765 13.4111 13.1918C13.1528 13.38 13 13.6804 13 14C13 14.3197 13.1528 14.62 13.4111 14.8083C13.4322 14.8236 14.1527 15.3479 15.0705 15.8727C15.5289 16.1349 16.0549 16.4078 16.5799 16.6178C17.0862 16.8202 17.6781 17 18.2426 17C18.8069 17 19.3986 16.8203 19.9048 16.6179C20.4297 16.4081 20.9556 16.1352 21.414 15.8731C22.1697 15.441 22.7919 15.0091 23 14.8613V19H18C17.4477 19 17 19.4477 17 20C17 20.5523 17.4477 21 18 21H19V25.3378C16.011 27.0669 14 30.2986 14 34C14 39.5229 18.4772 44 24 44C29.5228 44 34 39.5229 34 34C34 30.2986 31.989 27.0669 29 25.3378V21H30C30.5523 21 31 20.5523 31 20C31 19.4477 30.5523 19 30 19H25V14.8719C25.2216 15.0287 25.8322 15.4506 26.5705 15.8727C27.0289 16.1349 27.5549 16.4078 28.0799 16.6178C28.5862 16.8202 29.1781 17 29.7426 17C30.3069 17 30.8986 16.8203 31.4048 16.6179C31.9297 16.4081 32.4556 16.1352 32.914 15.8731C33.8316 15.3484 34.5523 14.8241 34.574 14.8083C34.8323 14.6201 34.9851 14.3197 34.9851 14C34.9851 13.6804 34.8323 13.38 34.574 13.1918C34.5523 13.176 33.8316 12.6517 32.914 12.1269C32.4556 11.8648 31.9297 11.592 31.4048 11.3821C30.8987 11.1797 30.3069 11 29.7426 11C29.1781 11 28.5862 11.1798 28.0799 11.3822C27.5549 11.5922 27.0289 11.8651 26.5705 12.1273C26.2703 12.299 25.9913 12.4706 25.7509 12.6243C25.7914 12.5555 25.8323 12.4854 25.8731 12.414C26.1352 11.9556 26.408 11.4297 26.6179 10.9048C26.8203 10.3987 27 9.8069 27 9.24256C27 8.67809 26.8202 8.08618 26.6178 7.57993C26.4078 7.05489 26.1349 6.52888 25.8727 6.07046C25.3478 5.15273 24.8235 4.43215 24.8082 4.41112ZM23.8634 7.06333C23.909 6.98354 23.9547 6.90535 24 6.82922C24.0452 6.90536 24.0909 6.98355 24.1366 7.06335C24.3729 7.47653 24.5976 7.91452 24.7607 8.32249C24.9314 8.74925 25 9.05936 25 9.24256C25 9.4257 24.9314 9.73571 24.7608 10.1623C24.5978 10.5702 24.3731 11.0081 24.1369 11.4212C24.0911 11.5012 24.0454 11.5796 24 11.6559C23.9546 11.5796 23.9088 11.5012 23.8631 11.4212C23.6269 11.0081 23.4022 10.5702 23.2392 10.1624C23.0686 9.73573 23 9.42571 23 9.24256C23 9.05936 23.0686 8.74923 23.2393 8.32247C23.4024 7.91451 23.6271 7.47651 23.8634 7.06333ZM16.0633 14.1366C15.9835 14.091 15.9054 14.0453 15.8292 14C15.9054 13.9548 15.9835 13.9091 16.0633 13.8634C16.4765 13.6271 16.9145 13.4024 17.3225 13.2393C17.7492 13.0686 18.0594 13 18.2426 13C18.4257 13 18.7357 13.0686 19.1623 13.2392C19.5702 13.4022 20.0081 13.6269 20.4212 13.8631C20.5012 13.9089 20.5796 13.9546 20.6559 14C20.5796 14.0454 20.5012 14.0912 20.4212 14.1369C20.0081 14.3731 19.5702 14.5978 19.1624 14.7608C18.7357 14.9314 18.4257 15 18.2426 15C18.0594 15 17.7492 14.9314 17.3225 14.7607C16.9145 14.5976 16.4765 14.3729 16.0633 14.1366ZM27.3292 14C27.4054 14.0453 27.4835 14.091 27.5633 14.1366C27.9765 14.3729 28.4145 14.5976 28.8225 14.7607C29.2492 14.9314 29.5594 15 29.7426 15C29.9257 15 30.2357 14.9314 30.6624 14.7608C31.0702 14.5978 31.5081 14.3731 31.9212 14.1369C32.0012 14.0912 32.0796 14.0454 32.1559 14C32.0796 13.9546 32.0012 13.9089 31.9212 13.8631C31.5081 13.6269 31.0702 13.4022 30.6623 13.2392C30.2357 13.0686 29.9257 13 29.7426 13C29.5594 13 29.2492 13.0686 28.8225 13.2393C28.4145 13.4024 27.9765 13.6271 27.5633 13.8634C27.4835 13.9091 27.4054 13.9548 27.3292 14ZM21 21H23L23 31H16.5813C17.2524 29.3415 18.4641 27.9584 20.0015 27.069L21 26.4914V21ZM25 21L25 31H31.4187C30.7476 29.3415 29.5359 27.9584 27.9985 27.069L27 26.4914V21H25ZM31.9381 33H16.0619C16.021 33.3276 16 33.6614 16 34C16 38.4183 19.5817 42 24 42C28.4183 42 32 38.4183 32 34C32 33.6614 31.979 33.3276 31.9381 33Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );