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="M7 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 10H7ZM12 16H30C34.4183 16 38 19.5817 38 24C38 28.4183 34.4183 32 30 32H12C11.4477 32 11 31.5523 11 31V17C11 16.4477 11.4477 16 12 16ZM9 17C9 15.3431 10.3431 14 12 14H30C35.5228 14 40 18.4772 40 24C40 29.5228 35.5228 34 30 34H12C10.3431 34 9 32.6569 9 31V17ZM36 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 24ZM15 18C13.8954 18 13 18.8954 13 20V28C13 29.1046 13.8954 30 15 30H26C27.1046 30 28 29.1046 28 28V20C28 18.8954 27.1046 18 26 18H15Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M14 23C14 20.7909 15.7909 19 18 19C20.2091 19 22 20.7909 22 23C22 25.2091 20.2091 27 18 27C15.7909 27 14 25.2091 14 23ZM18 21C16.8954 21 16 21.8954 16 23C16 24.1046 16.8954 25 18 25C19.1046 25 20 24.1046 20 23C20 21.8954 19.1046 21 18 21Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.1722 24.8534C25.2342 24.9085 25.25 24.9617 25.25 25C25.25 25.0402 25.232 25.0996 25.1581 25.1585C25.1507 25.1643 25.1435 25.1703 25.1363 25.1764L22.5113 27.4311C22.2733 27.6355 22.1877 27.9664 22.2967 28.2606C22.4057 28.5547 22.6863 28.75 23 28.75H26C26.4142 28.75 26.75 28.4142 26.75 28C26.75 27.5858 26.4142 27.25 26 27.25H25.0243L26.1044 26.3223C26.4841 26.0147 26.75 25.5462 26.75 25C26.75 23.9529 25.825 23.25 24.875 23.25H24.125C23.3615 23.25 22.647 23.6857 22.3671 24.3895C22.214 24.7744 22.402 25.2105 22.7869 25.3636C23.1718 25.5166 23.6079 25.3287 23.7609 24.9438C23.7899 24.8708 23.9088 24.75 24.125 24.75H24.875C25.006 24.75 25.1089 24.7971 25.1722 24.8534Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );