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.7071 6.29289C24.3166 5.90237 23.6834 5.90237 23.2929 6.29289L7.29289 22.2929C7.10536 22.4804 7 22.7348 7 23C7 24.2138 7.65829 25.2364 8.57157 25.9213C9.12075 26.3332 9.77937 26.6399 10.5 26.8189V39.5658C10.5 40.2981 11.0434 40.7152 11.3567 40.9002C11.7113 41.1096 12.1517 41.2553 12.5828 41.3644C13.4612 41.5867 14.5898 41.7264 15.6659 41.8172C16.7537 41.909 17.8364 41.9545 18.6438 41.9772C19.0483 41.9886 19.3858 41.9943 19.6227 41.9971C19.7412 41.9986 19.8347 41.9993 19.8989 41.9996L19.9729 42L19.9978 42H19.9997H21V35.2631C21 33.9001 22.1514 32.5 24 32.5C25.8486 32.5 27 33.9001 27 35.2631V42H28.0007H28.0022L28.0271 42L28.1011 41.9996C28.1653 41.9993 28.2588 41.9986 28.3773 41.9971C28.6142 41.9943 28.9517 41.9886 29.3562 41.9772C30.1636 41.9545 31.2463 41.909 32.3341 41.8172C33.4102 41.7264 34.5388 41.5867 35.4172 41.3644C35.8483 41.2553 36.2887 41.1096 36.6433 40.9002C36.9566 40.7152 37.5 40.2981 37.5 39.5658V26.8189C38.2206 26.6399 38.8793 26.3332 39.4284 25.9213C40.3417 25.2364 41 24.2138 41 23C41 22.7348 40.8946 22.4804 40.7071 22.2929L24.7071 6.29289ZM28 41C28 42 28.0007 42 28.0007 42L28 41ZM20 41L19.9997 42C19.9997 42 20 42 20 41ZM35.5 26.9867C34.4648 26.9312 33.4698 26.6982 32.6716 26.2374C32.4294 26.0975 32.203 25.9344 32 25.7485C31.797 25.9344 31.5706 26.0975 31.3284 26.2374C30.4023 26.772 29.2113 27 28 27C26.7887 27 25.5977 26.772 24.6716 26.2374C24.4294 26.0975 24.203 25.9344 24 25.7485C23.797 25.9344 23.5706 26.0975 23.3284 26.2374C22.4023 26.772 21.2113 27 20 27C18.7887 27 17.5977 26.772 16.6716 26.2374C16.4294 26.0975 16.203 25.9344 16 25.7485C15.797 25.9344 15.5706 26.0975 15.3284 26.2374C14.5302 26.6982 13.5352 26.9312 12.5 26.9867V39.2409C12.6267 39.2958 12.8145 39.3599 13.0735 39.4255C13.7888 39.6065 14.7852 39.7358 15.8341 39.8243C16.8713 39.9118 17.9136 39.9559 18.7 39.978C18.8049 39.9809 18.9051 39.9835 19 39.9857V35.2631C19 32.8014 21.0409 30.5 24 30.5C26.9591 30.5 29 32.8014 29 35.2631V39.9857C29.0949 39.9835 29.1951 39.9809 29.3 39.978C30.0864 39.9559 31.1287 39.9118 32.1659 39.8243C33.2148 39.7358 34.2112 39.6065 34.9265 39.4255C35.1855 39.3599 35.3733 39.2958 35.5 39.2409V26.9867ZM17.6715 24.5053C17.1849 24.2243 17 23.895 17 23.5C17 22.9477 16.5523 22.5 16 22.5C15.4477 22.5 15 22.9477 15 23.5C15 23.895 14.8151 24.2243 14.3285 24.5053C13.8068 24.8064 12.9979 25 12 25C11.0909 25 10.3063 24.7224 9.77157 24.3213C9.38051 24.028 9.14862 23.6937 9.05236 23.3619L11.9518 20.4624C12.6563 20.812 13.5057 21 14.3882 21C15.4302 21 16.421 20.7384 17.1833 20.2625C17.3239 20.1747 17.4615 20.0761 17.5922 19.967C17.7228 20.0761 17.8604 20.1747 18.0011 20.2625C18.7634 20.7384 19.7542 21 20.7961 21C21.8381 21 22.8289 20.7384 23.5912 20.2625C23.7318 20.1747 23.8694 20.0761 24.0001 19.967C24.1308 20.0761 24.2683 20.1747 24.409 20.2625C25.1713 20.7384 26.1621 21 27.204 21C28.246 21 29.2368 20.7384 29.9991 20.2625C30.1398 20.1747 30.2773 20.0761 30.408 19.967C30.5387 20.0761 30.6762 20.1747 30.8169 20.2625C31.5792 20.7384 32.57 21 33.612 21C34.4944 21 35.3438 20.8121 36.0483 20.4625L38.9476 23.3619C38.8514 23.6937 38.6195 24.028 38.2284 24.3213C37.6937 24.7224 36.9091 25 36 25C35.0021 25 34.1932 24.8064 33.6715 24.5053C33.1849 24.2243 33 23.895 33 23.5C33 22.9477 32.5523 22.5 32 22.5C31.4477 22.5 31 22.9477 31 23.5C31 23.895 30.8151 24.2243 30.3285 24.5053C29.8068 24.8064 28.9979 25 28 25C27.0021 25 26.1932 24.8064 25.6715 24.5053C25.1849 24.2243 25 23.895 25 23.5C25 22.9477 24.5523 22.5 24 22.5C23.4477 22.5 23 22.9477 23 23.5C23 23.895 22.8151 24.2243 22.3285 24.5053C21.8068 24.8064 20.9979 25 20 25C19.0021 25 18.1932 24.8064 17.6715 24.5053ZM18.4174 13.9968L13.5102 18.904C13.7747 18.9645 14.0699 19 14.3882 19C15.1158 19 15.7269 18.8139 16.1242 18.5659C16.5358 18.309 16.5922 18.0825 16.5922 18C16.5922 17.4477 17.0399 17 17.5922 17C18.1445 17 18.5922 17.4477 18.5922 18C18.5922 18.0825 18.6486 18.309 19.0601 18.5659C19.4574 18.8139 20.0686 19 20.7961 19C21.5237 19 22.1348 18.8139 22.5321 18.5659C22.9437 18.309 23.0001 18.0825 23.0001 18C23.0001 17.4477 23.4478 17 24.0001 17C24.5524 17 25.0001 17.4477 25.0001 18C25.0001 18.0825 25.0565 18.309 25.468 18.5659C25.8653 18.8139 26.4765 19 27.204 19C27.9316 19 28.5428 18.8139 28.9401 18.5659C29.3516 18.309 29.408 18.0825 29.408 18C29.408 17.4477 29.8557 17 30.408 17C30.9603 17 31.408 17.4477 31.408 18C31.408 18.0825 31.4644 18.309 31.8759 18.5659C32.2732 18.8139 32.8844 19 33.612 19C33.9302 19 34.2254 18.9645 34.4898 18.904L29.5826 13.9968C28.9122 14.9375 27.7421 15.5 26.5 15.5C25.5651 15.5 24.671 15.1813 24 14.6226C23.3291 15.1813 22.435 15.5 21.5 15.5C20.2579 15.5 19.0878 14.9375 18.4174 13.9968ZM19.8833 12.531C19.8977 12.5583 19.9111 12.5865 19.9232 12.6156C20.108 13.0595 20.6837 13.5 21.5 13.5C22.3163 13.5 22.892 13.0595 23.0769 12.6156C23.2321 12.2428 23.5962 12 24 12C24.4038 12 24.768 12.2428 24.9232 12.6156C25.108 13.0595 25.6837 13.5 26.5 13.5C27.3163 13.5 27.892 13.0595 28.0769 12.6156C28.089 12.5865 28.1023 12.5583 28.1168 12.531L24 8.41421L19.8833 12.531ZM35.6714 39.1479C35.6714 39.1479 35.668 39.1513 35.6584 39.1579C35.6661 39.1511 35.6714 39.1479 35.6714 39.1479ZM12.3286 39.1479C12.3286 39.1479 12.3339 39.1511 12.3416 39.1579C12.332 39.1513 12.3286 39.1479 12.3286 39.1479Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );