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 d="M32 26V22H33C34.1046 22 35 22.8954 35 24C35 25.1046 34.1046 26 33 26H32Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9 6C7.34315 6 6 7.34315 6 9V39C6 40.6569 7.34315 42 9 42H39C40.6569 42 42 40.6569 42 39V9C42 7.34315 40.6569 6 39 6H9ZM13 20C12.4477 20 12 20.4477 12 21C12 21.5523 12.4477 22 13 22H14V26H13C12.4477 26 12 26.4477 12 27C12 27.5523 12.4477 28 13 28H17C17.5523 28 18 27.5523 18 27C18 26.4477 17.5523 26 17 26H16V22H17C17.5523 22 18 21.5523 18 21C18 20.4477 17.5523 20 17 20H13ZM25.8557 22.3698C25.548 22.0621 25.156 21.8525 24.7292 21.7677C24.3025 21.6828 23.8601 21.7263 23.4581 21.8929C23.0561 22.0594 22.7126 22.3413 22.4708 22.7031C22.2291 23.0649 22.1 23.4903 22.1 23.9254C22.1 24.3605 22.2291 24.7859 22.4708 25.1476C22.7126 25.5094 23.0561 25.7914 23.4581 25.9579C23.8601 26.1244 24.3025 26.168 24.7292 26.0831C25.156 25.9982 25.548 25.7887 25.8557 25.481C26.2462 25.0905 26.8794 25.0905 27.2699 25.481C27.6604 25.8715 27.6604 26.5047 27.2699 26.8952C26.6825 27.4826 25.9341 27.8826 25.1194 28.0447C24.3047 28.2067 23.4602 28.1236 22.6928 27.8057C21.9253 27.4878 21.2694 26.9495 20.8079 26.2588C20.3464 25.5681 20.1 24.7561 20.1 23.9254C20.1 23.0947 20.3464 22.2827 20.8079 21.592C21.2694 20.9013 21.9253 20.363 22.6928 20.0451C23.4602 19.7272 24.3047 19.644 25.1194 19.8061C25.9341 19.9681 26.6825 20.3682 27.2699 20.9555C27.6604 21.3461 27.6604 21.9792 27.2699 22.3698C26.8794 22.7603 26.2462 22.7603 25.8557 22.3698ZM31 20C30.4477 20 30 20.4477 30 21V27C30 27.5523 30.4477 28 31 28H33C35.2091 28 37 26.2091 37 24C37 21.7909 35.2091 20 33 20H31Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );