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 14.5001C6.36628 14.0483 6.36628 13.3156 6.81815 12.8638L13.3636 6.31816C13.8155 5.86628 14.5481 5.86628 14.9999 6.31816C15.4518 6.77004 15.4518 7.50268 14.9999 7.95456L14.1823 8.77223L18.2726 12.8627L21.5454 9.58989C21.9972 9.13801 22.7299 9.13801 23.1817 9.58989C23.6336 10.0418 23.6336 10.7744 23.1817 11.2263L21.5449 12.8631L35.4545 26.773C37.132 28.4506 37.564 30.9021 36.7504 32.9782L37.9089 34.1367C38.5144 34.7422 38.7142 35.5999 38.5083 36.3718L41.1818 39.0454C41.6337 39.4973 41.6337 40.2299 41.1818 40.6818C40.7299 41.1337 39.9973 41.1337 39.5455 40.6818L36.8723 38.0086C36.1001 38.215 35.242 38.0153 34.6361 37.4095L33.4777 36.251C31.4016 37.0646 28.9502 36.6326 27.2727 34.955L26.8788 34.5612C26.9586 34.0525 27 33.531 27 33C27 32.3584 26.9396 31.7309 26.8241 31.1229L31.9 26.0469L20.1307 14.2774L14.7773 19.6309L18.22 23.0736C17.8201 23.025 17.413 23 17 23C16.469 23 15.9476 23.0413 15.439 23.1211L13.3631 21.0451L11.7272 22.6811C11.2753 23.133 10.5427 23.133 10.0909 22.6811C9.63899 22.2292 9.63899 21.4966 10.0909 21.0447L13.3636 17.7719L9.27321 13.6814L8.45451 14.5001C8.00264 14.952 7.27002 14.952 6.81815 14.5001ZM35.4545 34.955C35.3799 35.0296 35.3039 35.1016 35.2264 35.1713L36.0503 35.9952C36.173 36.1179 36.372 36.1179 36.4947 35.9952C36.6174 35.8725 36.6174 35.6736 36.4947 35.5509L35.6707 34.7269C35.6011 34.8044 35.529 34.8805 35.4545 34.955ZM34.0403 28.1873C35.1382 29.2853 35.4207 30.89 34.8877 32.2487L32.7482 34.3882C31.3895 34.9213 29.7848 34.6388 28.6869 33.5408L28.1829 33.0368L33.5363 27.6833L34.0403 28.1873ZM16.8585 14.2769L14.7778 16.3576L10.6874 12.2672L12.7681 10.1865L16.8585 14.2769ZM19.7574 37.1716C19.2326 37.5192 18.6384 37.7704 18 37.9V39C18.5523 39 19 39.4477 19 40C19 40.5523 18.5523 41 18 41H16C15.4477 41 15 40.5523 15 40C15 39.4477 15.4477 39 16 39V37.9C15.3616 37.7704 14.7674 37.5192 14.2426 37.1716L13.4142 38.0001C13.8047 38.3906 13.8047 39.0238 13.4142 39.4143C13.0236 39.8048 12.3905 39.8048 12 39.4143L10.5857 38.0001C10.1952 37.6096 10.1952 36.9764 10.5857 36.5859C10.9763 36.1953 11.6094 36.1953 12 36.5859L12.8284 35.7574C12.4808 35.2326 12.2296 34.6384 12.1 34H11C11 34.5523 10.5523 35 10 35C9.44772 35 9 34.5523 9 34V32C9 31.4477 9.44772 31 10 31C10.5523 31 11 31.4477 11 32H12.1C12.2296 31.3616 12.4808 30.7674 12.8284 30.2426L12 29.4143C11.6095 29.8048 10.9764 29.8048 10.5858 29.4143C10.1953 29.0238 10.1953 28.3906 10.5858 28.0001L11.2835 27.3024C11.2866 27.2992 11.2898 27.296 11.2929 27.2929C11.296 27.2897 11.2992 27.2866 11.3024 27.2835L12 26.5859C12.3906 26.1953 13.0237 26.1953 13.4143 26.5859C13.8048 26.9764 13.8048 27.6096 13.4143 28.0001L14.2426 28.8284C14.7674 28.4808 15.3616 28.2296 16 28.1V27C15.4477 27 15 26.5523 15 26C15 25.4477 15.4477 25 16 25H18C18.5523 25 19 25.4477 19 26C19 26.5523 18.5523 27 18 27V28.1C18.6384 28.2296 19.2326 28.4808 19.7574 28.8284L20.5858 27.9999C20.1953 27.6094 20.1953 26.9762 20.5858 26.5857C20.9764 26.1952 21.6095 26.1952 22 26.5857L23.4143 27.9999C23.8048 28.3904 23.8048 29.0236 23.4143 29.4141C23.0237 29.8047 22.3906 29.8047 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.5523 24.5523 35 24 35C23.4477 35 23 34.5523 23 34H21.9C21.7704 34.6384 21.5192 35.2326 21.1716 35.7574L22 36.5859C22.3906 36.1953 23.0237 36.1953 23.4143 36.5859C23.8048 36.9764 23.8048 37.6096 23.4143 38.0001L22 39.4143C21.6095 39.8048 20.9764 39.8048 20.5858 39.4143C20.1953 39.0238 20.1953 38.3906 20.5858 38.0001L19.7574 37.1716Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );