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="M43.9349 32.6489L38 18.9623V10H29V16H36V18H11.9381C10.5901 18 9.40179 18.869 9.01446 20.138L4.13073 34.138C3.54321 36.0628 5.00969 38 7.05433 38H29.2589C30.6069 38 31.7952 37.131 32.1825 35.862L36.9848 22.1289L41.592 32.3776L34.5 34.5L33.5 37L43.2941 33.9557L43.293 33.9522C43.295 33.9516 43.2969 33.951 43.2989 33.9504C43.3124 33.946 43.326 33.9413 43.3395 33.9363C43.8657 33.7424 44.1322 33.166 43.9349 32.6489ZM19.0299 31.7577C18.8959 32.2935 19.2217 32.8364 19.7575 32.9704C20.2933 33.1043 20.8362 32.7786 20.9701 32.2428L21.7808 29H25C25.5523 29 26 28.5523 26 28C26 27.4477 25.5523 27 25 27H22.2808L22.9701 24.2428C23.1041 23.707 22.7783 23.164 22.2425 23.0301C21.7067 22.8961 21.1638 23.2219 21.0299 23.7577L20.2193 27H17C16.4477 27 16 27.4477 16 28C16 28.5523 16.4477 29 17 29H19.7193L19.0299 31.7577Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );