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="M17 22.0228C15.8954 22.0228 15 22.9182 15 24.0228C15 25.1273 15.8954 26.0228 17 26.0228C18.1046 26.0228 19 25.1273 19 24.0228C19 22.9182 18.1046 22.0228 17 22.0228Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 10C5.34315 10 4 11.3431 4 13V35C4 36.6569 5.34315 38 7 38H41C42.6569 38 44 36.6569 44 35V13C44 11.3431 42.6569 10 41 10H7ZM24 20.0228H22V28.0228H24V20.0228ZM27.5352 20.0232L30 23.7205V20.0232H32L32 28.0232H30.4648L28 24.326V28.0232H26V20.0232H27.5352ZM38.4556 22.2227L39.3203 22.7249L40.3247 20.9954L39.4599 20.4932C39.0664 20.2647 38.6358 20.1011 38.1847 20.0114C37.3791 19.8511 36.5441 19.9334 35.7853 20.2477C35.0265 20.562 34.378 21.0942 33.9217 21.7771C33.4654 22.4601 33.2218 23.2629 33.2218 24.0843C33.2218 24.9056 33.4654 25.7085 33.9217 26.3914C34.378 27.0743 35.0265 27.6065 35.7853 27.9208C36.5441 28.2351 37.3791 28.3174 38.1847 28.1571C38.6358 28.0674 39.0664 27.9039 39.4599 27.6753L40.3247 27.1731L39.3203 25.4436L38.4556 25.9458C38.2515 26.0643 38.0283 26.1491 37.7945 26.1956C37.3769 26.2786 36.9441 26.236 36.5507 26.0731C36.1574 25.9101 35.8212 25.6342 35.5846 25.2802C35.3481 24.9262 35.2218 24.51 35.2218 24.0843C35.2218 23.6585 35.3481 23.2423 35.5846 22.8883C35.8212 22.5343 36.1574 22.2584 36.5507 22.0954C36.9441 21.9325 37.3769 21.8899 37.7945 21.9729C38.0283 22.0195 38.2515 22.1042 38.4556 22.2227ZM13 24.0228C13 21.8136 14.7909 20.0228 17 20.0228C19.2091 20.0228 21 21.8136 21 24.0228C21 26.2319 19.2091 28.0228 17 28.0228C14.7909 28.0228 13 26.2319 13 24.0228ZM10 20.0228H8V28.0228H12.5V26.0228H10V20.0228Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );