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="M24 17.2222L22.4227 20.4067L20.6305 19.519L23.0827 14.5681C23.4579 13.8106 24.5421 13.8106 24.9173 14.5681L27.3695 19.519L25.5773 20.4067L24 17.2222ZM30.2222 26.4626C29.9811 26.6967 29.8711 27.0341 29.928 27.3647L30.8647 32.8062C31.008 33.6388 30.1309 34.2738 29.3805 33.8807L24.476 31.3115C24.178 31.1554 23.822 31.1554 23.524 31.3115L18.6195 33.8807C17.8691 34.2738 16.992 33.6388 17.1353 32.8062L18.072 27.3647C18.1289 27.0341 18.0189 26.6967 17.7778 26.4626L13.81 22.6089C13.2029 22.0193 13.5379 20.9919 14.3769 20.8704L19.8603 20.0765C20.1935 20.0283 20.4815 19.8198 20.6305 19.519L22.4227 20.4067C21.9808 21.2988 21.1287 21.9137 20.1469 22.0559L16.6348 22.5644L19.1713 25.0279L17.8609 26.377L19.1713 25.0279C19.8848 25.7209 20.2121 26.7216 20.043 27.704L19.4427 31.1917L22.596 29.5399C23.4752 29.0793 24.5248 29.0793 25.4041 29.5399L28.5573 31.1917L27.957 27.704C27.7879 26.7216 28.1152 25.7209 28.8287 25.0279L30.2222 26.4626ZM31.3652 22.5644L27.8531 22.0559C26.8713 21.9137 26.0192 21.2988 25.5773 20.4067L27.3695 19.519C27.5185 19.8198 27.8065 20.0283 28.1397 20.0765L33.6231 20.8704C34.4621 20.9919 34.7971 22.0193 34.19 22.6089L30.2222 26.4626L28.8287 25.0279L31.3652 22.5644Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );