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="M32 10V12H30V18H27C26.397 18 25.8355 17.8221 25.3652 17.5158C24.6394 17.8274 23.8399 18 23 18C19.6863 18 17 15.3137 17 12C17 8.68629 19.6863 6 23 6C25.6124 6 27.8349 7.66962 28.6586 10L32 10ZM19.5351 10C20.2267 8.8044 21.5194 8 23 8C24.4806 8 25.7733 8.8044 26.4649 10H19.5351ZM19 12C19 14.2091 20.7909 16 23 16C23.3886 16 23.7643 15.9446 24.1195 15.8412C24.0417 15.5743 24 15.292 24 15V12L19 12ZM26 15C26 15.5523 26.4477 16 27 16H28V12H26V15Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M15 21.3542C14.2671 20.5238 13.1947 20 12 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9C8.44772 18 8 18.4477 8 19C8 19.5523 8.44772 20 9 20H10C7.79086 20 6 21.7909 6 24V30C6 32.2091 7.79086 34 10 34H10.0538C10.3109 36.3508 11.4735 38.2796 13.2099 39.6491C15.1667 41.1925 17.8124 42 20.6594 42C24.8482 42 28.7463 40.448 30.4419 36.9481C31.85 37.2164 33.2886 36.4411 33.809 35.0534C34.1582 34.1221 34.0146 33.1267 33.5083 32.354L36.4412 30.86L35.5334 29.0779L31.6684 31.0467L26 28.921V23C26 21.3431 24.6569 20 23 20H18C16.8053 20 15.7329 20.5238 15 21.3542ZM8 24C8 22.8954 8.89543 22 10 22H12C13.1046 22 14 22.8954 14 24V30C14 31.1046 13.1046 32 12 32H10C8.89543 32 8 31.1046 8 30V24ZM14.4126 33.1908C13.759 33.6857 12.9487 33.9845 12.0693 33.9994C12.3108 35.6978 13.171 37.0713 14.4485 38.0788C15.9876 39.2928 18.1716 40 20.6594 40C24.334 40 27.2207 38.7127 28.5335 36.2791L24.6307 34.8155C23.5303 36.1496 21.8644 37 20 37C17.4594 37 15.2877 35.421 14.4126 33.1908ZM22.5885 34.0497L21.9466 33.809C20.7757 33.3699 20 32.2505 20 31V26C20 24.3431 21.3431 23 23 23C23.3506 23 23.6872 23.0602 24 23.1707V23C24 22.4477 23.5523 22 23 22H18C16.8954 22 16 22.8954 16 24V31C16 33.2091 17.7909 35 20 35C20.9872 35 21.8908 34.6424 22.5885 34.0497ZM24 28.921C24 29.7547 24.5171 30.5009 25.2978 30.7937L31.3511 33.0637C31.8682 33.2576 32.1302 33.834 31.9363 34.3511C31.7424 34.8682 31.166 35.1302 30.6489 34.9363L22.6489 31.9363C22.2586 31.79 22 31.4168 22 31V26C22 25.4477 22.4477 25 23 25C23.5523 25 24 25.4477 24 26V28.921Z" fill="black"/>
<path d="M40.152 24.47L41.848 25.53L40.3042 28H42V30H36.6958L40.152 24.47Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );