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="M11.5065 9.04068C9.87223 9.31306 8.76817 10.8587 9.04055 12.4931L13.0406 36.4931C13.2491 37.7446 14.2225 38.7296 15.4715 38.953C16.7205 39.1764 17.975 38.5899 18.6045 37.4883L23.9997 28.0466L29.395 37.4883C30.0245 38.5899 31.279 39.1764 32.528 38.953C33.7769 38.7296 34.7503 37.7446 34.9589 36.4931L38.9589 12.4931C39.2313 10.8587 38.1272 9.31306 36.4929 9.04068C34.8586 8.76829 33.3129 9.87235 33.0406 11.5067L30.4253 27.198L26.6045 20.5114C26.0703 19.5767 25.0763 18.9999 23.9997 18.9999C22.9232 18.9999 21.9291 19.5767 21.395 20.5114L17.5741 27.198L14.9589 11.5067C14.6865 9.87235 13.1409 8.76829 11.5065 9.04068ZM11.0133 12.1643C10.9225 11.6195 11.2906 11.1043 11.8353 11.0135C12.3801 10.9227 12.8953 11.2907 12.9861 11.8355L16.0629 30.2963C16.1325 30.7135 16.4569 31.0418 16.8733 31.1163C17.2896 31.1908 17.7077 30.9953 17.9176 30.6281L23.1315 21.5037C23.3095 21.1921 23.6409 20.9999 23.9997 20.9999C24.3586 20.9999 24.6899 21.1921 24.868 21.5037L30.0819 30.6281C30.2917 30.9953 30.7099 31.1908 31.1262 31.1163C31.5425 31.0418 31.867 30.7135 31.9365 30.2963L35.0133 11.8355C35.1041 11.2907 35.6194 10.9227 36.1641 11.0135C36.7089 11.1043 37.0769 11.6195 36.9861 12.1643L32.9861 36.1643C32.9166 36.5814 32.5921 36.9098 32.1758 36.9842C31.7595 37.0587 31.3413 36.8632 31.1315 36.496L24.868 25.5348C24.6899 25.2233 24.3586 25.031 23.9997 25.031C23.6409 25.031 23.3095 25.2233 23.1315 25.5348L16.868 36.496C16.6581 36.8632 16.24 37.0587 15.8237 36.9842C15.4073 36.9098 15.0829 36.5814 15.0133 36.1643L11.0133 12.1643Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );