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="M13.3097 7.44597C13.3374 7.19223 13.5528 7 13.8093 7H17.2781C17.5346 7 17.75 7.19223 17.7777 7.44597L17.9963 9.44597C18.0286 9.74176 17.7957 10 17.4966 10H13.5908C13.2917 10 13.0588 9.74176 13.0911 9.44597L13.3097 7.44597Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.2541 4.42852C10.2899 4.18254 10.5018 4 10.7516 4H20.3357C20.5855 4 20.7974 4.18254 20.8331 4.42852L21.9947 12.4285C22.0385 12.73 21.8035 13 21.4973 13H16.549V20H9.9931V17.2714H3.98349V12H3.50981C2.38889 12 1.65984 10.8266 2.16114 9.82921L3.65994 6.84725C4.21562 5.74168 5.8016 5.74167 6.35729 6.84725L7.85609 9.82921C8.35738 10.8266 7.62834 12 6.50742 12H5.99398V15.2714H12.0036V18H14.5386V13H9.58999C9.2838 13 9.04875 12.73 9.09253 12.4285L10.2541 4.42852ZM11.3313 11L12.0573 6H19.03L19.756 11H11.3313ZM5.09853 8.81499C5.06148 8.74128 4.95575 8.74128 4.9187 8.81499L4.39581 9.85531C4.36239 9.9218 4.411 10 4.48572 10H5.5315C5.60623 10 5.65484 9.9218 5.62142 9.85531L5.09853 8.81499Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );