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" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="24" stroke-width="1.5" fill="white"/>
<path d="M18 8.75004C18 -0.250032 6 -0.249992 6 8.75004V10.25L4.37231 10.25C3.78861 10.25 3.54858 10.999 4.02356 11.3383L6 12.75C5.66667 13.9167 4.3 16.45 1.5 17.25C1.83333 17.75 2.8 18.75 4 18.75L5 20.25L7.5 19.75C8.33333 20.4167 10.4 21.75 12 21.75C13.6 21.75 15.6667 20.4167 16.5 19.75L19 20.25L20 18.75C21.2 18.75 22.1667 17.75 22.5 17.25C19.7 16.45 18.3333 13.9167 18 12.75L19.9764 11.3383C20.4514 10.999 20.2114 10.25 19.6277 10.25L18 10.25V8.75004Z" stroke="currentColor"  stroke-linecap="round" stroke-linejoin="round"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );