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="M29.5913 4.67461C28.7899 4.21665 27.8914 4 26.9237 4H21.6761C19.8516 4 18.0073 4.84975 16.8974 6.38697C16.8603 6.43373 16.8241 6.48089 16.7886 6.52844L14.4522 9.55709L13.6409 10.639L13.6394 10.641C11.1085 13.9837 11.109 18.6379 13.6409 21.98L13.6468 21.9878L23.424 34.3903L30.0001 42.7749C30.7148 43.6861 32.0516 43.8018 32.9121 43.0268L36.9781 39.3654C37.7571 38.6639 37.8623 37.4799 37.2191 36.6521L29.789 27.0891L24.9969 21.0313L19.5739 14.0266C20.1663 13.6875 20.8665 13.5093 21.5857 13.5093H26.8333C27.4959 13.5093 28.1756 13.7018 28.7743 14.027L25.439 18.3351L26.5721 19.7987L31.0119 25.4114C30.9935 25.2769 30.9839 25.1395 30.9839 25V22C29.3345 21.9913 28 20.6515 28 19C28 15.708 30.6491 13.059 33.9068 13.001C33.9324 13.0003 33.9581 13 33.9839 13H34.0161C34.0419 13 34.0676 13.0003 34.0932 13.001C34.8584 13.0146 35.5899 13.1712 36.2615 13.4454C35.9465 12.4205 35.4525 11.4389 34.7795 10.5501L33.9666 9.46626L33.9584 9.45546L31.6269 6.43315L31.6156 6.41806L31.6279 6.40924C31.0533 5.60468 30.276 5.06587 29.5913 4.67461ZM21.5857 11.5093C20.4633 11.5093 19.3185 11.8098 18.3445 12.4332C17.8617 11.7461 17.6094 10.8772 17.6094 10.0667C17.6094 9.25167 17.8657 8.43472 18.3831 7.73584L18.4982 7.5867L18.5089 7.57171C19.2104 6.58966 20.4332 6 21.6761 6H26.9237C27.5847 6 28.1338 6.14525 28.599 6.4111C29.1501 6.726 29.6182 7.07085 29.9466 7.49893L29.932 7.5104L30.032 7.64012C31.076 9.05023 31.0686 11.0296 30.0098 12.4317C29.0758 11.8619 27.9649 11.5093 26.8333 11.5093H21.5857Z" fill="black"/>
<path d="M36 19C36 17.9057 35.111 17.0086 34 17.0001C32.889 17.0086 32 17.9057 32 19C32 19.5523 31.5523 20 31 20C30.4477 20 30 19.5523 30 19C30 16.8072 31.7684 15.0345 33.9521 15.0005C33.9563 15.0004 33.9606 15.0003 33.9649 15.0002C33.9712 15.0001 33.9776 15 33.9839 15H34.016C34.0267 15 34.0373 15.0002 34.0479 15.0005C36.2315 15.0345 38 16.8072 38 19C38 20.8689 36.7153 22.4327 34.9839 22.8749V25C34.9839 25.5523 34.5362 26 33.9839 26C33.4316 26 32.9839 25.5523 32.9839 25V22C32.9839 21.4477 33.4316 21 33.9839 21C35.1024 21 36 20.0995 36 19Z" fill="black"/>
<path d="M21.4555 35.9317L16.5675 29.728L10.8372 37.0603C10.1498 37.9399 10.3155 39.2119 11.2054 39.886L15.5838 43.203C16.4538 43.8621 17.6916 43.702 18.3652 42.8431L22.6207 37.4173L21.4603 35.9377L21.4555 35.9317Z" fill="black"/>
<path d="M35 28C35 28.5523 34.5523 29 34 29C33.4477 29 33 28.5523 33 28C33 27.4477 33.4477 27 34 27C34.5523 27 35 27.4477 35 28Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );