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="M30 12H7C6.44772 12 6 12.4477 6 13V17.8496L7.23494 19.5477C7.73217 20.2314 8 21.055 8 21.9004V26.0996C8 26.945 7.73217 27.7686 7.23494 28.4523L6 30.1504V35C6 35.5523 6.44772 36 7 36H30C36.6274 36 42 30.6274 42 24C42 17.3726 36.6274 12 30 12ZM7 10C5.34315 10 4 11.3431 4 13V17.8496C4 18.2723 4.13392 18.6841 4.38253 19.026L5.61747 20.724C5.86608 21.0659 6 21.4777 6 21.9004V26.0996C6 26.5223 5.86608 26.9341 5.61747 27.276L4.38253 28.974C4.13392 29.3159 4 29.7277 4 30.1504V35C4 36.6569 5.34315 38 7 38H30C37.732 38 44 31.732 44 24C44 16.268 37.732 10 30 10H7Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30 16H13C12.4477 16 12 16.4477 12 17V31C12 31.5523 12.4477 32 13 32H30C34.4183 32 38 28.4183 38 24C38 19.5817 34.4183 16 30 16ZM13 14C11.3431 14 10 15.3431 10 17V31C10 32.6569 11.3431 34 13 34H30C35.5228 34 40 29.5228 40 24C40 18.4772 35.5228 14 30 14H13Z" fill="black"/>
<path d="M36 24C36 25.6569 34.6569 27 33 27C31.3431 27 30 25.6569 30 24C30 22.3431 31.3431 21 33 21C34.6569 21 36 22.3431 36 24Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M14 20C14 18.8954 14.8954 18 16 18H27C28.1046 18 29 18.8954 29 20V28C29 29.1046 28.1046 30 27 30H16C14.8954 30 14 29.1046 14 28V20ZM15 23C15 20.7909 16.7909 19 19 19C21.2091 19 23 20.7909 23 23C23 25.2091 21.2091 27 19 27C16.7909 27 15 25.2091 15 23ZM19 21C17.8954 21 17 21.8954 17 23C17 24.1046 17.8954 25 19 25C20.1046 25 21 24.1046 21 23C21 21.8954 20.1046 21 19 21ZM26.25 25C26.25 24.9617 26.2342 24.9085 26.1722 24.8535C26.1089 24.7971 26.006 24.75 25.875 24.75H25.125C24.9088 24.75 24.7899 24.8708 24.7609 24.9438C24.6079 25.3287 24.1718 25.5166 23.7869 25.3636C23.402 25.2105 23.214 24.7744 23.3671 24.3895C23.647 23.6857 24.3615 23.25 25.125 23.25H25.875C26.825 23.25 27.75 23.9529 27.75 25C27.75 25.5462 27.4841 26.0147 27.1044 26.3223L26.0243 27.25H27C27.4142 27.25 27.75 27.5858 27.75 28C27.75 28.4142 27.4142 28.75 27 28.75H24C23.6863 28.75 23.4057 28.5547 23.2967 28.2606C23.1877 27.9664 23.2733 27.6355 23.5113 27.4311L26.1363 25.1764C26.1435 25.1703 26.1507 25.1643 26.1581 25.1585C26.232 25.0996 26.25 25.0402 26.25 25Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );