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 d="M23 22.9217C23 22.396 23.4743 22.0001 24 22.0001C24.5257 22.0001 25 22.396 25 22.9217V41C25 41.5523 24.5523 42 24 42C23.4477 42 23 41.5523 23 41V22.9217Z" fill="black"/>
<path d="M28 16C28 14.1362 26.7252 12.5701 25 12.126V7C25 6.44772 24.5523 6 24 6C23.4477 6 23 6.44772 23 7V12.126C21.2748 12.5701 20 14.1362 20 16C20 18.2091 21.7909 20 24 20C26.2091 20 28 18.2091 28 16Z" fill="black"/>
<path d="M12 36C14.2091 36 16 34.2091 16 32C16 30.1362 14.7252 28.5701 13 28.126L13 7C13 6.44772 12.5523 6 12 6C11.4477 6 11 6.44772 11 7V28.126C9.27477 28.5701 8 30.1362 8 32C8 34.2091 9.79086 36 12 36Z" fill="black"/>
<path d="M36 33.0001C35.4743 33.0001 35 33.396 35 33.9217V41C35 41.5523 35.4477 42 36 42C36.5523 42 37 41.5523 37 41V33.9217C37 33.396 36.5257 33.0001 36 33.0001Z" fill="black"/>
<path d="M37 23.126C38.7252 23.5701 40 25.1362 40 27C40 29.2091 38.2091 31 36 31C33.7909 31 32 29.2091 32 27C32 25.1362 33.2748 23.5701 35 23.126V7C35 6.44772 35.4477 6 36 6C36.5523 6 37 6.44772 37 7V23.126Z" fill="black"/>
<path d="M11 38.9217C11 38.396 11.4743 38.0001 12 38.0001C12.5257 38.0001 13 38.396 13 38.9217V41C13 41.5523 12.5523 42 12 42C11.4477 42 11 41.5523 11 41V38.9217Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );