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="M24 40C32.8366 40 40 32.8366 40 24C40 15.1634 32.8366 8 24 8C15.1634 8 8 15.1634 8 24C8 32.8366 15.1634 40 24 40ZM24 42C33.9411 42 42 33.9411 42 24C42 14.0589 33.9411 6 24 6C14.0589 6 6 14.0589 6 24C6 33.9411 14.0589 42 24 42Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.5 20C30.2239 20 30 20.2239 30 20.5C30 20.7761 30.2239 21 30.5 21C30.7761 21 31 20.7761 31 20.5C31 20.2239 30.7761 20 30.5 20ZM28 20.5C28 19.1193 29.1193 18 30.5 18C31.8807 18 33 19.1193 33 20.5C33 21.8807 31.8807 23 30.5 23C29.1193 23 28 21.8807 28 20.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.5 20C17.2239 20 17 20.2239 17 20.5C17 20.7761 17.2239 21 17.5 21C17.7761 21 18 20.7761 18 20.5C18 20.2239 17.7761 20 17.5 20ZM15 20.5C15 19.1193 16.1193 18 17.5 18C18.8807 18 20 19.1193 20 20.5C20 21.8807 18.8807 23 17.5 23C16.1193 23 15 21.8807 15 20.5Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M16 31C16 30.4477 16.4477 30 17 30L31 30C31.5523 30 32 30.4477 32 31C32 31.5523 31.5523 32 31 32L17 32C16.4477 32 16 31.5523 16 31Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );