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="M28.3148 13.5C27.8107 13.5 27.3848 13.8726 27.3196 14.3707L26.7305 18.8707C26.6521 19.4692 27.1199 20 27.7257 20H38.4873C39.0932 20 39.5609 19.4692 39.4826 18.8707L38.8935 14.3707C38.8283 13.8726 38.4023 13.5 37.8982 13.5H28.3148ZM29.1961 15.5L28.8688 18H37.3442L37.0169 15.5H29.1961Z" fill="black"/>
<path d="M33.1066 23C33.6609 23 34.1103 22.5523 34.1103 22C34.1103 21.4477 33.6609 21 33.1066 21C32.5523 21 32.1029 21.4477 32.1029 22C32.1029 22.5523 32.5523 23 33.1066 23Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.1496 10C24.6481 10 24.2236 10.3688 24.1553 10.8638L22.2232 24.8638C22.1403 25.4646 22.6089 26 23.2175 26H32.1029V36H23.5717V30.3478H11.0257V24H12.9078C15.2363 24 16.7507 21.5569 15.7094 19.4805L12.8236 13.7263C11.6693 11.4246 8.3748 11.4246 7.22049 13.7263L4.33472 19.4805C3.2934 21.5569 4.80783 24 7.13629 24H9.01838V32.3478H21.5643V38H34.1103V26H42.9962C43.6048 26 44.0734 25.4646 43.9905 24.8638L42.0584 10.8638C41.9901 10.3688 41.5656 10 41.0641 10H25.1496ZM26.0247 12L24.3687 24H41.845L40.189 12H26.0247ZM9.01838 21.9181H7.13629C6.36013 21.9181 5.85533 21.1037 6.20243 20.4116L9.0882 14.6573C9.47297 13.8901 10.5711 13.8901 10.9559 14.6573L13.8417 20.4116C14.1888 21.1037 13.684 21.9181 12.9078 21.9181H11.0257V20.5C11.0257 19.9477 10.5764 19.5 10.0221 19.5C9.46774 19.5 9.01838 19.9477 9.01838 20.5V21.9181Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );