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="M6 9C6 7.34315 7.34315 6 9 6H39C40.6569 6 42 7.34315 42 9V39C42 40.6569 40.6569 42 39 42H9C7.34315 42 6 40.6569 6 39V9ZM18.0577 36.5L19.6211 37.5071C20.2866 37.9358 21.1626 37.458 21.1626 36.6664L21.1627 32.7586C21.1627 32.4514 21.0215 32.1613 20.7798 31.9717L14.0934 26.7277C13.6515 26.3811 13.0109 26.4663 12.6749 26.9163L10.5988 29.6977C10.2682 30.1407 10.3596 30.7678 10.803 31.0979L18.0577 36.5ZM28.5431 37.5071L30.1065 36.5L37.3612 31.0979C37.8045 30.7678 37.896 30.1407 37.5653 29.6977L35.4892 26.9163C35.1533 26.4663 34.5127 26.3811 34.0707 26.7277L27.3844 31.9717C27.1427 32.1613 27.0015 32.4514 27.0015 32.7586L27.0015 36.6664C27.0015 37.458 27.8776 37.9358 28.5431 37.5071ZM32.4291 23.2747C32.3405 23.916 32.2526 24.5523 32.2722 25.2711L32.5015 25.9999L27.4473 29.9999L26.7181 29.142C26.2443 28.4093 26 27.9999 25.5 26.9999C25 25.9999 25 24.9999 25 24.9999L25.0001 23.2744C25.0001 22.3133 25.0001 21.3929 25 19.066C24.9999 18 26.1518 18.3417 26.746 18.8478C27.3402 19.354 27.4032 19.795 27.4032 19.795L27.9889 22.8892C27.9889 22.8892 27.9838 20.0947 27.8452 19.066C27.7926 18.6758 27.4802 18.1328 27.1186 17.5041C26.9973 17.2932 26.8705 17.0727 26.746 16.8451C26.58 16.5413 26.4328 16.2827 26.2984 16.0465C25.99 15.5044 25.7488 15.0803 25.5001 14.5C24.1403 11.3271 25.9229 11.6797 26.7203 12.1438C27.5178 12.6078 31.4 16.6412 31.908 17.4107C32.3057 18.0134 32.3788 18.8229 32.4612 19.7362C32.484 19.9891 32.5075 20.25 32.5389 20.5167C32.6636 21.5777 32.5458 22.4305 32.4291 23.2747ZM15.892 25.2711C15.9116 24.5523 15.8237 23.916 15.7351 23.2747C15.6184 22.4305 15.5006 21.5777 15.6253 20.5167C15.6567 20.25 15.6802 19.9891 15.703 19.7362C15.7854 18.8229 15.8584 18.0134 16.2562 17.4107C16.7642 16.6412 20.6464 12.6078 21.4439 12.1438C22.2413 11.6797 24.0239 11.3271 22.6641 14.5C22.4154 15.0803 22.1741 15.5044 21.8658 16.0465C21.7314 16.2827 21.5842 16.5413 21.4182 16.8451C21.2937 17.0727 21.1669 17.2932 21.0456 17.5041C20.684 18.1328 20.3716 18.6758 20.319 19.066C20.1804 20.0947 20.1753 22.8892 20.1753 22.8892L20.761 19.795C20.761 19.795 20.824 19.354 21.4182 18.8478C22.0123 18.3417 23.1642 18 23.1642 19.066C23.164 21.3944 23.1641 22.3144 23.1641 23.2762C23.1642 23.773 23.1642 24.2809 23.1642 24.9999C23.1642 24.9999 23.1642 25.9999 22.6642 26.9999C22.1642 27.9999 21.9198 28.4093 21.446 29.142L20.7168 29.9999L15.6627 25.9999L15.892 25.2711Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );