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.81815 12.8638C6.36628 13.3156 6.36628 14.0483 6.81815 14.5001C7.27002 14.952 8.00264 14.952 8.45451 14.5001L9.27321 13.6814L13.3636 17.7719L10.0909 21.0447C9.63899 21.4966 9.63899 22.2292 10.0909 22.6811C10.5427 23.133 11.2753 23.133 11.7272 22.6811L13.3631 21.0451L15.439 23.1211C15.9476 23.0413 16.469 23 17 23C17.413 23 17.8201 23.025 18.22 23.0736L14.7773 19.6309L20.1307 14.2774L31.9 26.0469L26.8241 31.1229C26.9395 31.7309 27 32.3584 27 33C27 33.531 26.9586 34.0525 26.8788 34.5612L27.2727 34.955C28.9502 36.6326 31.4016 37.0646 33.4777 36.251L34.6361 37.4095C35.242 38.0153 36.1001 38.215 36.8723 38.0086L39.5455 40.6818C39.9973 41.1337 40.7299 41.1337 41.1818 40.6818C41.6337 40.2299 41.6337 39.4973 41.1818 39.0454L38.5083 36.3718C38.7142 35.5999 38.5144 34.7422 37.9089 34.1367L36.7504 32.9782C37.564 30.9021 37.132 28.4506 35.4545 26.773L21.5449 12.8631L23.1817 11.2263C23.6336 10.7744 23.6336 10.0418 23.1817 9.58989C22.7299 9.13801 21.9972 9.13801 21.5454 9.58989L18.2726 12.8627L14.1823 8.77223L14.9999 7.95456C15.4518 7.50268 15.4518 6.77004 14.9999 6.31816C14.5481 5.86628 13.8155 5.86628 13.3636 6.31816L6.81815 12.8638ZM32.7482 34.3882L34.8877 32.2487C35.4207 30.89 35.1382 29.2853 34.0403 28.1873L33.5363 27.6833L28.1829 33.0368L28.6869 33.5408C29.7848 34.6388 31.3895 34.9213 32.7482 34.3882ZM36.0503 35.9952L35.2264 35.1713C35.3039 35.1016 35.3799 35.0296 35.4545 34.955C35.529 34.8805 35.6011 34.8044 35.6707 34.7269L36.4947 35.5509C36.6174 35.6736 36.6174 35.8725 36.4947 35.9952C36.372 36.1179 36.173 36.1179 36.0503 35.9952ZM16.8585 14.2769L12.7681 10.1865L10.6874 12.2672L14.7778 16.3576L16.8585 14.2769Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.2426 28.8284C14.7674 28.4808 15.3616 28.2296 16 28.1V27C15.4477 27 15 26.5522 15 26C15 25.4477 15.4477 25 16 25H18C18.5523 25 19 25.4477 19 26C19 26.5522 18.5523 27 18 27V28.1C18.6383 28.2296 19.2326 28.4808 19.7574 28.8284L20.5858 27.9999C20.1953 27.6094 20.1953 26.9762 20.5858 26.5857C20.9763 26.1951 21.6095 26.1951 22 26.5857L23.4142 27.9999C23.8048 28.3904 23.8048 29.0236 23.4142 29.4141C23.0237 29.8046 22.3905 29.8046 22 29.4141L21.1716 30.2426C21.5192 30.7674 21.7704 31.3616 21.9 32H23C23 31.4477 23.4477 31 24 31C24.5523 31 25 31.4477 25 32V34C25 34.5522 24.5523 35 24 35C23.4477 35 23 34.5522 23 34H21.9C21.7704 34.6383 21.5192 35.2325 21.1716 35.7573L22 36.5858C22.3905 36.1953 23.0237 36.1953 23.4142 36.5858C23.8048 36.9763 23.8048 37.6095 23.4142 38L22 39.4142C21.6095 39.8048 20.9763 39.8048 20.5858 39.4142C20.1953 39.0237 20.1953 38.3906 20.5858 38L19.7574 37.1716C19.2326 37.5192 18.6383 37.7704 18 37.8999V39C18.5523 39 19 39.4477 19 40C19 40.5522 18.5523 41 18 41H16C15.4477 41 15 40.5522 15 40C15 39.4477 15.4477 39 16 39V37.8999C15.3616 37.7704 14.7674 37.5192 14.2426 37.1716L13.4141 38C13.8047 38.3906 13.8047 39.0237 13.4141 39.4142C13.0236 39.8048 12.3904 39.8048 11.9999 39.4142L10.5857 38C10.1952 37.6095 10.1952 36.9763 10.5857 36.5858C10.9762 36.1953 11.6094 36.1953 11.9999 36.5858L12.8284 35.7573C12.4808 35.2325 12.2296 34.6383 12.1 34H11C11 34.5522 10.5523 35 9.99997 35C9.44769 35 8.99997 34.5522 8.99997 34V32C8.99997 31.4477 9.44769 31 9.99997 31C10.5523 31 11 31.4477 11 32H12.1C12.2296 31.3616 12.4808 30.7674 12.8284 30.2426L12 29.4142C11.6095 29.8048 10.9763 29.8048 10.5858 29.4142C10.1953 29.0237 10.1953 28.3906 10.5858 28L11.2835 27.3023L11.2929 27.2929L11.3023 27.2835L12 26.5858C12.3905 26.1953 13.0237 26.1953 13.4142 26.5858C13.8048 26.9763 13.8048 27.6095 13.4142 28L14.2426 28.8284ZM14 33C14 31.3431 15.3431 30 17 30C18.6568 30 20 31.3431 20 33C20 34.6568 18.6568 36 17 36C15.3431 36 14 34.6568 14 33Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );