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="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.29292 4.29314C4.68345 3.90261 5.31661 3.90261 5.70714 4.29314L7.98127 6.56727C10.5764 5.56326 13.4539 5.56691 16.047 6.57822C18.4065 7.49845 20.382 9.19535 21.6476 11.3891L21.9628 11.9353C21.9858 11.9753 21.9858 12.0245 21.9628 12.0645L21.6476 12.6107C20.7308 14.1999 19.4415 15.5283 17.9036 16.4896L19.8493 18.4353C20.2398 18.8258 20.2398 19.459 19.8493 19.8495C19.4587 20.24 18.8256 20.24 18.4351 19.8495L16.0183 17.4327C13.4233 18.4366 10.546 18.4328 7.95309 17.4216C5.59353 16.5014 3.61805 14.8045 2.35243 12.6107L2.03733 12.0645C2.01425 12.0245 2.01425 11.9753 2.03733 11.9353L2.35243 11.3891C3.26915 9.80012 4.5583 8.4718 6.09606 7.51049L4.29292 5.70735C3.9024 5.31683 3.9024 4.68366 4.29292 4.29314ZM4.32211 11.9999C4.56203 11.6281 4.82769 11.2757 5.11646 10.945L10.169 15.9975C9.66409 15.8943 9.16585 15.7479 8.67978 15.5583C6.88563 14.8586 5.36215 13.6115 4.32211 11.9999ZM13.0711 16.0712L6.59025 9.59038C6.89819 9.36417 7.22068 9.15701 7.55597 8.9704L14.4374 15.8518C13.9699 15.9812 13.4946 16.0726 13.0162 16.1262L13.0711 16.0712ZM15.6712 14.2572C15.8299 14.0215 15.965 13.77 16.0743 13.5062C16.2889 12.988 16.3994 12.4325 16.3994 11.8716C16.3994 11.3107 16.2889 10.7552 16.0743 10.237C15.8596 9.71879 15.545 9.24792 15.1484 8.85129C14.8193 8.52227 14.4392 8.24969 14.0234 8.04378C12.5529 7.70988 11.0196 7.74467 9.56216 8.14816L10.707 9.29304C10.7547 9.27026 10.8031 9.24872 10.852 9.22845C11.216 9.07769 11.6061 9.00009 12 9.00009C12.394 9.00009 12.7841 9.07769 13.1481 9.22845C13.197 9.24871 13.2453 9.27024 13.293 9.293C13.112 9.47396 13 9.72397 13 10.0001C13 10.5524 13.4478 11.0001 14 11.0001C14.2762 11.0001 14.5262 10.8882 14.7072 10.7072C14.7299 10.7549 14.7514 10.8032 14.7717 10.852C14.9224 11.216 15 11.6061 15 12.0001C15 12.3941 14.9224 12.7842 14.7717 13.1481C14.7514 13.1971 14.7299 13.2454 14.7071 13.2931L15.6712 14.2572ZM17.6117 14.2568C17.6256 14.2247 17.6393 14.1924 17.6528 14.16C17.9533 13.4345 18.108 12.6569 18.108 11.8716C18.108 11.1855 17.9899 10.5054 17.7597 9.86064C18.5041 10.4651 19.1527 11.186 19.678 11.9999C19.1182 12.8673 18.4184 13.6291 17.6117 14.2568Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );