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="M29.9999 4C27.2385 4 24.9999 6.39847 24.9999 9.35714V29.7546C23.171 31.2208 21.9999 33.4736 21.9999 36C21.9999 40.4183 25.5816 44 29.9999 44C34.4182 44 37.9999 40.4183 37.9999 36C37.9999 33.4736 36.8288 31.2208 34.9999 29.7546V9.35714C34.9999 6.39847 32.7613 4 29.9999 4ZM32.9999 22.061C31.5428 22.0854 30.1777 21.7313 28.9823 21.4212C28.2524 21.2319 27.5857 21.0589 26.9999 20.9986V9.35714C26.9999 7.58194 28.3431 6.14286 29.9999 6.14286C31.6568 6.14286 32.9999 7.58194 32.9999 9.35714V9.97595H30.9999C30.4476 9.97595 29.9999 10.4237 29.9999 10.976C29.9999 11.5282 30.4476 11.976 30.9999 11.976H32.9999V13.976H30.9999C30.4476 13.976 29.9999 14.4237 29.9999 14.976C29.9999 15.5282 30.4476 15.976 30.9999 15.976H32.9999V17.976H30.9999C30.4476 17.976 29.9999 18.4237 29.9999 18.976C29.9999 19.5282 30.4476 19.976 30.9999 19.976H32.9999V22.061Z" fill="black"/>
<path d="M16.3301 12C16.3301 11.4477 15.8824 11 15.3301 11C14.7778 11 14.3301 11.4477 14.3301 12V15.268L11.5 13.6341C11.0217 13.3579 10.4101 13.5218 10.134 14.0001C9.85782 14.4784 10.0217 15.09 10.5 15.3661L13.3299 17L10.4999 18.6339C10.0216 18.91 9.85776 19.5216 10.1339 19.9999C10.41 20.4782 11.0216 20.6421 11.4999 20.3659L14.3301 18.7319V22C14.3301 22.5523 14.7778 23 15.3301 23C15.8824 23 16.3301 22.5523 16.3301 22V18.7321L19.1602 20.3661C19.6385 20.6423 20.2501 20.4784 20.5263 20.0001C20.8024 19.5218 20.6385 18.9102 20.1602 18.6341L17.3299 17L20.1602 15.3659C20.6385 15.0898 20.8023 14.4782 20.5262 13.9999C20.2501 13.5216 19.6385 13.3577 19.1602 13.6339L16.3301 15.2678V12Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );