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.8787 9.87877C25.7367 9.02077 27.027 8.76411 28.1481 9.22845C29.2691 9.69279 30 10.7867 30 12.0001L30 36.0001C30 37.6569 28.6569 39.0001 27 39.0001C25.3431 39.0001 24 37.6569 24 36.0001L24 19.2363C22.8221 20.2916 21.0106 20.2534 19.8787 19.1214C18.7071 17.9498 18.7071 16.0503 19.8787 14.8788L24.8787 9.87877ZM27.3827 11.0762C27.009 10.9214 26.5789 11.007 26.2929 11.293L21.2929 16.293C20.9024 16.6835 20.9024 17.3167 21.2929 17.7072C21.6834 18.0977 22.3166 18.0977 22.7071 17.7072L24.2929 16.1214C24.5789 15.8354 25.009 15.7499 25.3827 15.9046C25.7564 16.0594 26 16.4241 26 16.8285L26 36.0001C26 36.5524 26.4477 37.0001 27 37.0001C27.5523 37.0001 28 36.5524 28 36.0001L28 12.0001C28 11.5956 27.7564 11.231 27.3827 11.0762Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );