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 d="M11.9045 12.5C11.2826 12.5 11 12.9036 11 13.15C11 13.5642 10.6642 13.9 10.25 13.9C9.83579 13.9 9.5 13.5642 9.5 13.15C9.5 11.85 10.6989 11 11.9045 11C13.1102 11 14.3091 11.85 14.3091 13.15C14.3091 14.2193 13.4974 14.9539 12.5273 15.2048V15.25C12.5273 15.6642 12.1915 16 11.7773 16C11.3631 16 11.0273 15.6642 11.0273 15.25V14.58C11.0273 14.1417 11.3822 13.8049 11.7983 13.7999C12.556 13.7906 12.8091 13.3573 12.8091 13.15C12.8091 12.9036 12.5264 12.5 11.9045 12.5Z" fill="black"/>
<path d="M12.5 17.25C12.5 17.6642 12.1642 18 11.75 18C11.3358 18 11 17.6642 11 17.25C11 16.8358 11.3358 16.5 11.75 16.5C12.1642 16.5 12.5 16.8358 12.5 17.25Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.8984 21.0002H4.0627C3.33295 21.0002 2.84896 20.2439 3.1547 19.5812L10.8463 2.91208C11.1995 2.1468 12.2828 2.1348 12.6528 2.89208L20.7969 19.5612C21.1215 20.2256 20.6378 21.0002 19.8984 21.0002ZM5.62545 19.0002H18.2969L11.7801 5.66189L5.62545 19.0002Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );