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="M12 9C12.5523 9 13 8.55228 13 8C13 7.44772 12.5523 7 12 7H8C7.44772 7 7 7.44772 7 8V12C7 12.5523 7.44772 13 8 13C8.55228 13 9 12.5523 9 12V10.4143L14.7528 16.1671C14.8598 16.2741 14.985 16.3518 15.1184 16.4001C14.4037 17.7772 14 19.3414 14 21C14 26.1854 17.9466 30.4489 23 30.9507V36.9301H21C20.4477 36.9301 20 37.3778 20 37.9301C20 38.4824 20.4477 38.9301 21 38.9301H23V41C23 41.5523 23.4477 42 24 42C24.5522 42 25 41.5523 25 41V38.9301H27C27.5522 38.9301 28 38.4824 28 37.9301C28 37.3778 27.5522 36.9301 27 36.9301H25V30.9507C30.0533 30.4489 34 26.1854 34 21C34 19.3769 33.6132 17.8441 32.9269 16.4887L35.0312 14.3976L36.4609 15.8273C36.8514 16.2178 37.4846 16.2178 37.8751 15.8273C38.2656 15.4367 38.2656 14.8036 37.8751 14.4131L36.4499 12.9878L39 10.4537V12.0001C39 12.5524 39.4477 13.0001 40 13.0001C40.5523 13.0001 41 12.5524 41 12.0001V8.00008C41 7.4478 40.5523 7.00008 40 7.00008H36C35.4477 7.00008 35 7.4478 35 8.00008C35 8.55237 35.4477 9.00008 36 9.00008H37.6255L35.0357 11.5736L33.6325 10.1704C33.242 9.77989 32.6088 9.77989 32.2183 10.1704C31.8277 10.5609 31.8277 11.1941 32.2183 11.5846L33.617 12.9834L31.8211 14.768C29.9888 12.4716 27.1662 11 24 11C20.8345 11 18.0125 12.4708 16.1802 14.7663L16.167 14.7529L10.4141 9H12ZM24 13C19.5817 13 16 16.5818 16 21C16 25.4183 19.5817 29 24 29C28.4182 29 32 25.4183 32 21C32 16.5818 28.4182 13 24 13Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );